湿料计划(修改湿料计划)

highway
wws 1 year ago
parent 97083e9206
commit e86bddaf1c

@ -129,4 +129,11 @@ public interface ProWetMaterialPlanMapper {
* @return * @return
*/ */
ProWetMaterialPlan selectProWetMaterialPlanByWorkId(String workorderId); ProWetMaterialPlan selectProWetMaterialPlanByWorkId(String workorderId);
/**
* id湿
* @param workorderId
* @return
*/
ProWetMaterialPlan selectProWetMaterialPlanByWorkIdN(String workorderId);
} }

@ -19,6 +19,7 @@ import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.dto.WCSDataDTO; import com.op.system.api.domain.dto.WCSDataDTO;
import com.op.system.api.domain.dto.WCSDataItemsDTO; import com.op.system.api.domain.dto.WCSDataItemsDTO;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -29,6 +30,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import static com.op.common.core.web.domain.AjaxResult.error; import static com.op.common.core.web.domain.AjaxResult.error;
@ -51,6 +53,7 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
// //
// @Value("${wcs.url1}") // @Value("${wcs.url1}")
// public String materialPlanSyncUrl; // public String materialPlanSyncUrl;
/** /**
* 湿 * 湿
* *
@ -117,9 +120,9 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
// 已下发计划不允许删除 // 已下发计划不允许删除
for (String id : ids) { for (String id : ids) {
ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanById(id); ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanById(id);
if (plan.getSyncFlag().equals("Y")){ if (plan.getSyncFlag().equals("Y")) {
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
return error("日期为"+formatDate.format(plan.getPlanTime())+"的计划已下发,不允许删除!"); return error("日期为" + formatDate.format(plan.getPlanTime()) + "的计划已下发,不允许删除!");
} }
} }
for (String id : ids) { for (String id : ids) {
@ -248,12 +251,39 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
@DS("#header.poolName") @DS("#header.poolName")
public AjaxResult getWetMaterialPlanDetailListById(String id) { public AjaxResult getWetMaterialPlanDetailListById(String id) {
List<ProWetMaterialPlanDetail> detailList = proWetMaterialPlanDetailMapper.selectProWetMaterialPlanDetailListById(id); List<ProWetMaterialPlanDetail> detailList = proWetMaterialPlanDetailMapper.selectProWetMaterialPlanDetailListById(id);
// 获取班次名称和料罐名称 // 湿料详情数据处理(去重)
List<ProWetMaterialPlanDetail> tempList = new ArrayList<>();
for (ProWetMaterialPlanDetail detail : detailList) { for (ProWetMaterialPlanDetail detail : detailList) {
ProWetMaterialPlanDetail temp = new ProWetMaterialPlanDetail();
// 获取班次名称和料罐名称
detail.setShiftDesc(proWetMaterialPlanMapper.selectShiftById(String.valueOf(detail.getShiftId()))); detail.setShiftDesc(proWetMaterialPlanMapper.selectShiftById(String.valueOf(detail.getShiftId())));
detail.setBucketName(proWetMaterialPlanMapper.selectBucketNameById(detail.getBucketId())); detail.setBucketName(proWetMaterialPlanMapper.selectBucketNameById(detail.getBucketId()));
BeanUtils.copyProperties(detail,temp);
if (tempList.size() == 0) {
tempList.add(temp);
}else {
boolean check = true;
for (ProWetMaterialPlanDetail data : tempList) {
// 找到重复
if (data.getWorkorderCode().equals(temp.getWorkorderCode())) {
check = false;
StringBuilder bucketName = new StringBuilder(data.getBucketName());
bucketName.append(",").append(temp.getBucketName());
data.setBucketName(bucketName.toString());
}
}
if (check) {
tempList.add(temp);
}
}
} }
return success(detailList); return success(tempList);
} }
/** /**
@ -267,19 +297,27 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
@Transactional @Transactional
public AjaxResult updateWetMaterialPlanDetail(List<ProWetMaterialPlanDetail> detailList) { public AjaxResult updateWetMaterialPlanDetail(List<ProWetMaterialPlanDetail> detailList) {
// 获取该计划详情下的主计划信息 // 获取该计划详情下的主计划信息
ProWetMaterialPlan proWetMaterialPlan = proWetMaterialPlanMapper.selectProWetMaterialPlanById(detailList.get(0).getWetMaterialPlanId()); ProWetMaterialPlan proWetMaterialPlan = proWetMaterialPlanMapper.selectProWetMaterialPlanByWorkIdN(detailList.get(0).getWorkorderId());
// 更新主计划信息 // 更新主计划信息
// 更新人 // 更新人
proWetMaterialPlan.setUpdateBy(SecurityContextHolder.getUserName()); proWetMaterialPlan.setUpdateBy(SecurityContextHolder.getUserName());
// 更新时间 // 更新时间
proWetMaterialPlan.setUpdateTime(DateUtils.getNowDate()); proWetMaterialPlan.setUpdateTime(DateUtils.getNowDate());
// 更新至数据库
proWetMaterialPlanMapper.updateProWetMaterialPlan(proWetMaterialPlan); proWetMaterialPlanMapper.updateProWetMaterialPlan(proWetMaterialPlan);
// 循环将详情信息更新至数据库 // 删除所有详情信息
proWetMaterialPlanDetailMapper.deleteProWetMaterialPlanDetailByPlanId(proWetMaterialPlan.getId());
for (ProWetMaterialPlanDetail detail : detailList) { for (ProWetMaterialPlanDetail detail : detailList) {
proWetMaterialPlanDetailMapper.updateProWetMaterialPlanDetail(detail); ProOrderWorkorder workOrder = new ProOrderWorkorder();
BeanUtils.copyProperties(detail,workOrder);
workOrder.setShiftId(String.valueOf(detail.getShiftId()));
workOrder.setBucketId(Integer.valueOf(detail.getBucketId()));
workOrder.setMaterialId(Integer.valueOf(detail.getMaterialId()));
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(workOrder,proWetMaterialPlan.getId()));
} }
// throw new RuntimeException();
return success(); return success();
} }
@ -293,8 +331,8 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
@DS("#header.poolName") @DS("#header.poolName")
public AjaxResult checkChangePlan(String id) { public AjaxResult checkChangePlan(String id) {
List<ProWetMaterialPlanDetail> list = proWetMaterialPlanDetailMapper.selectProWetMaterialPlanDetailByOrderId(id); List<ProWetMaterialPlanDetail> list = proWetMaterialPlanDetailMapper.selectProWetMaterialPlanDetailByOrderId(id);
if (list.size()>0){ if (list.size() > 0) {
return error(500,"计划已接料!不可修改!"); return error(500, "计划已接料!不可修改!");
} }
return success(); return success();
} }
@ -471,29 +509,29 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
return detail; return detail;
} }
public static void main(String args[]){ public static void main(String args[]) {
List<ProWetMaterialPlanDetail> planDetails = new ArrayList<>(); List<ProWetMaterialPlanDetail> planDetails = new ArrayList<>();
ProWetMaterialPlanDetail d1=new ProWetMaterialPlanDetail(); ProWetMaterialPlanDetail d1 = new ProWetMaterialPlanDetail();
d1.setBucketCode("LG1"); d1.setBucketCode("LG1");
d1.setMaterialCode("WL00001"); d1.setMaterialCode("WL00001");
planDetails.add(d1); planDetails.add(d1);
ProWetMaterialPlanDetail d2=new ProWetMaterialPlanDetail(); ProWetMaterialPlanDetail d2 = new ProWetMaterialPlanDetail();
d2.setBucketCode("LG2"); d2.setBucketCode("LG2");
d2.setMaterialCode("WL00002"); d2.setMaterialCode("WL00002");
planDetails.add(d2); planDetails.add(d2);
ProWetMaterialPlanDetail d3=new ProWetMaterialPlanDetail(); ProWetMaterialPlanDetail d3 = new ProWetMaterialPlanDetail();
d3.setBucketCode("LG1"); d3.setBucketCode("LG1");
d3.setMaterialCode("WL00001"); d3.setMaterialCode("WL00001");
planDetails.add(d3); planDetails.add(d3);
//罐 //罐
// List<String> gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode).distinct().collect(Collectors.toList()); // List<String> gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode).distinct().collect(Collectors.toList());
// //
// List<ProWetMaterialPlanDetail> glList = planDetails.stream() // List<ProWetMaterialPlanDetail> glList = planDetails.stream()
// .map(e -> new ProWetPlanDetailDTO(e.getBucketCode(), e.getMaterialCode())) // .map(e -> new ProWetPlanDetailDTO(e.getBucketCode(), e.getMaterialCode()))
// .collect(Collectors.toList()); // .collect(Collectors.toList());
//罐-料 //罐-料
Map<String, String> mapStream = planDetails.stream() Map<String, String> mapStream = planDetails.stream()
.collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode,ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1)); .collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode, ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1));
System.out.println(mapStream); System.out.println(mapStream);
} }
} }

@ -117,7 +117,7 @@
<include refid="selectProOrderWorkorderVo"/> <include refid="selectProOrderWorkorderVo"/>
where workorder_id not in ( where workorder_id not in (
select workorder_id select workorder_id
from pro_wet_material_plan_detail) from pro_wet_material_plan_detail where del_flag = '0')
and CONVERT(date, product_date) = #{productDate} and prod_type = 'white' and CONVERT(date, product_date) = #{productDate} and prod_type = 'white'
and del_flag = '0' and del_flag = '0'
</select> </select>

@ -100,8 +100,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, factory_code, plan_time, sync_flag, create_by, create_time, update_by, update_time, select id, factory_code, plan_time, sync_flag, create_by, create_time, update_by, update_time,
order_type, prod_code, prod_desc, prod_source, quantity, unit, atrr1, atrr2, atrr3, status, order_type, prod_code, prod_desc, prod_source, quantity, unit, atrr1, atrr2, atrr3, status,
prod_type, plan_code, shift_id, shift_desc from pro_wet_material_plan prod_type, plan_code, shift_id, shift_desc from pro_wet_material_plan
where id = (select wet_material_plan_id from pro_wet_material_plan_detail where id = (select TOP 1 wet_material_plan_id from pro_wet_material_plan_detail
where workorder_id = #{workorderId}) and sync_flag = 'Y' and del_flag = '0' where workorder_id = #{workorderId} and del_flag = '0') and sync_flag = 'Y' and del_flag = '0'
</select>
<select id="selectProWetMaterialPlanByWorkIdN" resultType="com.op.plan.domain.ProWetMaterialPlan">
select id, factory_code, plan_time, sync_flag, create_by, create_time, update_by, update_time,
order_type, prod_code, prod_desc, prod_source, quantity, unit, atrr1, atrr2, atrr3, status,
prod_type, plan_code, shift_id, shift_desc from pro_wet_material_plan
where id = (select TOP 1 wet_material_plan_id from pro_wet_material_plan_detail
where workorder_id = #{workorderId} and del_flag = '0') and sync_flag = 'N' and del_flag = '0'
</select> </select>
<insert id="insertProWetMaterialPlan" parameterType="ProWetMaterialPlan"> <insert id="insertProWetMaterialPlan" parameterType="ProWetMaterialPlan">

Loading…
Cancel
Save