package cn.stylefeng.guns.modular.om.productionOrdeInfo.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.service.BomInfoService;
|
import cn.stylefeng.guns.modular.om.productionOrdeInfo.entity.ProductionOrdeInfo;
|
import cn.stylefeng.guns.modular.om.productionOrdeInfo.mapper.ProductionOrdeInfoMapper;
|
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam;
|
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult;
|
import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService;
|
import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.entity.ProductionOrderBatchInfo;
|
import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam;
|
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.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* <p>
|
* 生产工单 服务实现类
|
* </p>
|
*
|
* @author cl
|
* @since 2022-10-25
|
*/
|
@Service
|
public class ProductionOrdeInfoServiceImpl extends ServiceImpl<ProductionOrdeInfoMapper, ProductionOrdeInfo> implements ProductionOrdeInfoService {
|
/* private static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
private static String date = format.format(new Date());
|
private static String orderDate = "M"+date;*/
|
@Autowired
|
private ProductionOrdeInfoService productionOrdeInfoService;
|
|
@Autowired
|
private ProductionOrderBatchInfoService orderBatchInfoService;
|
|
@Autowired
|
private BomInfoService bomInfoService;
|
|
@Override
|
public void add(ProductionOrdeInfoParam param){
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
String date = format.format(new Date());
|
String orderDate = "M"+date;
|
|
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().like("work_order_no", date));
|
if(workOrderNo.size() == 0){
|
param.setWorkOrderNo(orderDate+"0001");
|
}else {
|
param.setWorkOrderNo(orderDate+String.format("%04d", workOrderNo.size()+1));
|
}
|
ProductionOrdeInfo one = productionOrdeInfoService.getOne(new QueryWrapper<ProductionOrdeInfo>()
|
.select("MAX(serial_number) as serial_number")
|
);
|
if(one!=null){
|
param.setSerialNumber(one.getSerialNumber()+1);
|
}else {
|
param.setSerialNumber(new Long("1"));
|
}
|
ProductionOrdeInfo entity = getEntity(param);
|
this.save(entity);
|
}
|
|
@Override
|
public void delete(ProductionOrdeInfoParam param){
|
this.removeById(getKey(param));
|
}
|
|
@Override
|
public void update(ProductionOrdeInfoParam param){
|
//点击开始按钮 更新实际开始时间
|
// if(param.getFlag()!=null){
|
// param.setActualStartTime(new Date());
|
// }
|
ProductionOrdeInfo oldEntity = getOldEntity(param);
|
ProductionOrdeInfo newEntity = getEntity(param);
|
ToolUtil.copyProperties(newEntity, oldEntity);
|
this.updateById(newEntity);
|
}
|
|
@Override
|
public ProductionOrdeInfoResult findBySpec(ProductionOrdeInfoParam param){
|
return null;
|
}
|
|
@Override
|
public List<ProductionOrdeInfoResult> findListBySpec(ProductionOrdeInfoParam param){
|
return this.baseMapper.customList(param);
|
}
|
|
@Override
|
public LayuiPageInfo findPageBySpec(ProductionOrdeInfoParam param){
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
Page pageContext = getPageContext();
|
IPage page = this.baseMapper.customPageList(pageContext, param);
|
List<ProductionOrdeInfoResult> results = page.getRecords();
|
for (ProductionOrdeInfoResult result : results) {
|
try{
|
result.setPlanEndTimeString(format.format(result.getPlanEndTime()));
|
result.setPlanStartTimeString(format.format(result.getPlanStartTime()));
|
}catch (Exception e){
|
|
}
|
}
|
return LayuiPageFactory.createPageInfo(page);
|
}
|
|
@Override
|
public List lineFinishQty() {
|
return this.baseMapper.lineFinishQty();
|
}
|
|
@Override
|
public void saveOrderBatchInfo(ProductionOrdeInfoParam productionOrdeInfoParam) {
|
List<BomInfo> productCode = bomInfoService.list(new QueryWrapper<BomInfo>()
|
.eq("product_code", productionOrdeInfoParam.getMaterialCode())
|
.isNotNull("location_code")
|
);
|
List<ProductionOrderBatchInfo> workOrderNo = orderBatchInfoService.list(new QueryWrapper<ProductionOrderBatchInfo>().eq("work_order_no", productionOrdeInfoParam.getWorkOrderNo()));
|
if(workOrderNo.size()==0){
|
for (BomInfo bomInfo : productCode) {
|
ProductionOrderBatchInfo param = new ProductionOrderBatchInfo();
|
param.setWorkOrderNo(productionOrdeInfoParam.getWorkOrderNo());
|
param.setProductionLine(productionOrdeInfoParam.getProductionLine());
|
param.setLocationCode(bomInfo.getLocationCode());
|
param.setLoadingCode(bomInfo.getLoadingCode());
|
param.setMaterialCode(bomInfo.getMaterialCode());
|
param.setState("否");
|
param.setSpareField1("0");
|
param.setSpareField2(bomInfo.getLineCode());
|
param.setCreateTime(new Date());
|
orderBatchInfoService.save(param);
|
}
|
}
|
}
|
|
@Override
|
public HashMap getOrderWeek() {
|
return baseMapper.getOrderWeek();
|
}
|
|
@Override
|
public Integer getPlanQtyByDate(String str) {
|
return baseMapper.getPlanQtyByDate(str);
|
}
|
|
@Override
|
public Integer getActualQtyByDate(String str) {
|
return baseMapper.getActualQtyByDate(str);
|
}
|
|
@Override
|
public List<ProductionOrdeInfoResult> getListMonth() {
|
return baseMapper.getListMonth();
|
}
|
|
@Override
|
public List<ProductionOrdeInfoResult> getColumnarDate() {
|
return baseMapper.getColumnarDate();
|
}
|
|
@Override
|
public List<ProductionOrdeInfoResult> orderDescListFive() {
|
return baseMapper.orderDescListFive();
|
}
|
|
private Serializable getKey(ProductionOrdeInfoParam param){
|
return param.getId();
|
}
|
|
private Page getPageContext() {
|
return LayuiPageFactory.defaultPage();
|
}
|
|
private ProductionOrdeInfo getOldEntity(ProductionOrdeInfoParam param) {
|
return this.getById(getKey(param));
|
}
|
|
private ProductionOrdeInfo getEntity(ProductionOrdeInfoParam param) {
|
ProductionOrdeInfo entity = new ProductionOrdeInfo();
|
ToolUtil.copyProperties(param, entity);
|
return entity;
|
}
|
|
}
|