package cn.stylefeng.guns.modular.bs.bomInfo.service.impl; import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory; import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; import cn.stylefeng.guns.modular.bs.bomInfo.entity.BomInfo; import cn.stylefeng.guns.modular.bs.bomInfo.mapper.BomInfoMapper; import cn.stylefeng.guns.modular.bs.bomInfo.model.params.BomInfoParam; import cn.stylefeng.guns.modular.bs.bomInfo.model.result.BomInfoResult; import cn.stylefeng.guns.modular.bs.bomInfo.service.BomInfoService; import cn.stylefeng.guns.modular.dq.materialTraceability.entity.MaterialTraceability; import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.entity.ProductionOrderBatchInfo; import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; import cn.stylefeng.roses.core.util.ToolUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.Serializable; import java.util.List; /** *

* bom信息 服务实现类 *

* * @author * @since 2022-10-24 */ @Service public class BomInfoServiceImpl extends ServiceImpl implements BomInfoService { @Autowired private ProductionOrderBatchInfoService batchInfoService; @Autowired private MaterialTraceabilityService materialTraceabilityService; @Autowired private BomInfoMapper bomInfoMapper; @Override public void add(BomInfoParam param){ BomInfo entity = getEntity(param); this.save(entity); } @Override public void delete(BomInfoParam param){ this.removeById(getKey(param)); } @Override public void update(BomInfoParam param){ BomInfo oldEntity = getOldEntity(param); BomInfo newEntity = getEntity(param); ToolUtil.copyProperties(newEntity, oldEntity); this.updateById(newEntity); } @Override public BomInfoResult findBySpec(BomInfoParam param){ return null; } @Override public List findListBySpec(BomInfoParam param){ return this.baseMapper.customList(param); } @Override public LayuiPageInfo findPageBySpec(BomInfoParam param){ Page pageContext = getPageContext(); IPage page = this.baseMapper.customPageList(pageContext, param); return LayuiPageFactory.createPageInfo(page); } @Override public LayuiPageInfo kbListTable(BomInfoParam param) { Page pageContext = getPageContext(); IPage page = bomInfoMapper.kbListTable(pageContext, param); return LayuiPageFactory.createPageInfo(page); } @Override public LayuiPageInfo viewList(BomInfoParam param) { Page pageContext = getPageContext(); IPage page = this.baseMapper.customPageList(pageContext, param); List bomInfoResults = page.getRecords(); for (BomInfoResult bomInfoResult : bomInfoResults) { List list = materialTraceabilityService.list(new QueryWrapper() .eq("product_code", param.getProductCode()) .eq("work_order_no", param.getWorkorderNo()) .eq("location_code", param.getLocationCode()) ); if (list.size()>0){ for (MaterialTraceability materialTraceability : list) { if(bomInfoResult.getMaterialCode().equals(materialTraceability.getMaterialCode())){ bomInfoResult.setState("是"); break; }else { bomInfoResult.setState("否"); } } }else { bomInfoResult.setState("否"); } } return LayuiPageFactory.createPageInfo(page); } private Serializable getKey(BomInfoParam param){ return param.getId(); } private Page getPageContext() { return LayuiPageFactory.defaultPage(); } private BomInfo getOldEntity(BomInfoParam param) { return this.getById(getKey(param)); } private BomInfo getEntity(BomInfoParam param) { BomInfo entity = new BomInfo(); ToolUtil.copyProperties(param, entity); return entity; } }