update 添加创建盘点单方法
This commit is contained in:
parent
844a699e31
commit
1699c92edf
@ -1,12 +1,14 @@
|
||||
package com.cim.idm.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cim.idm.framework.IDMFrameServiceProxy;
|
||||
import com.cim.idm.framework.data.EventInfo;
|
||||
import com.cim.idm.framework.util.time.TimeStampUtil;
|
||||
import com.cim.idm.model.CheckMark;
|
||||
import com.cim.idm.model.CheckPlan;
|
||||
import com.cim.idm.service.Impl.CheckPlanServiceImpl;
|
||||
import com.cim.idm.service.Impl.ReturnStockIntoServiceImpl;
|
||||
import com.cim.idm.service.impl.ToSAPServiceImpl;
|
||||
import com.cim.idm.utils.AjaxResult;
|
||||
@ -22,10 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 盘点 标记
|
||||
@ -38,6 +37,9 @@ import java.util.Map;
|
||||
public class CheckMarkController {
|
||||
@Autowired
|
||||
private ToSAPServiceImpl toSAPServiceImpl;
|
||||
|
||||
@Autowired
|
||||
private com.cim.idm.service.Impl.CheckPlanServiceImpl CheckPlanServiceImpl;
|
||||
@RequestMapping(value = "/createMark", method = RequestMethod.POST)
|
||||
public AjaxResult createMark(@RequestBody JSONObject in ) throws Exception{
|
||||
|
||||
@ -248,4 +250,54 @@ public class CheckMarkController {
|
||||
|
||||
return AjaxResult.me().setResultObj(null);
|
||||
}
|
||||
/**
|
||||
* 创建盘点单
|
||||
* @param in 参数
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/createCheckPlan", method = RequestMethod.POST)
|
||||
public AjaxResult CreateCheckPlan(@RequestBody JSONObject in ) throws Exception {
|
||||
AjaxResult ajaxResult = new AjaxResult();
|
||||
String user = (String) in.get("USER");
|
||||
String palanDate = (String) in.get("PLANDATE");
|
||||
String checkPlanName = (String) in.get("CHECKPLANNAME");
|
||||
String moveFlag = (String) in.get("MOVEFLAG");
|
||||
String siteName = (String) in.get("SITENAME");
|
||||
|
||||
//3、遍历map中的值
|
||||
JSONArray boxListArray = in.getJSONArray("BOXLIST");
|
||||
// 创建一个列表来存储转换后的 LinkedHashMap
|
||||
List<LinkedHashMap<String, String>> boxList = new ArrayList<>();
|
||||
// 遍历 JSONArray 并转换为 LinkedHashMap
|
||||
for (int i = 0; i < boxListArray.size(); i++) {
|
||||
JSONObject jsonObject = boxListArray.getJSONObject(i);
|
||||
LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
|
||||
// 将每个字段添加到 LinkedHashMap 中
|
||||
for (String key : jsonObject.keySet()) {
|
||||
linkedHashMap.put(key, jsonObject.getString(key));
|
||||
}
|
||||
// 添加到列表中
|
||||
boxList.add(linkedHashMap);
|
||||
}
|
||||
if("全盘".equals(boxList.get(0).get("PLANTYPE").toString())){
|
||||
//如果是全盘,校验所选盘点日期是否已经创建过盘带单
|
||||
String querySql = " SELECT * FROM CHECKPLAN" +
|
||||
" WHERE SITENAME =:SITENAME AND PLANDATE =:PLANDATE AND PLANTYPE =:PLANTYPE ";
|
||||
Map<String, Object> qeuryMap = new HashMap<String, Object> ();
|
||||
qeuryMap.put("SITENAME", siteName);
|
||||
qeuryMap.put("PLANDATE", palanDate);
|
||||
qeuryMap.put("PLANTYPE", boxList.get(0).get("PLANTYPE").toString());
|
||||
List<Map<String, Object>> queryCheckPlanList = IDMFrameServiceProxy.getSqlTemplate().queryForList(querySql, qeuryMap);
|
||||
if(null != queryCheckPlanList && queryCheckPlanList.size() > 0){
|
||||
return AjaxResult.me().setSuccess(true).setMessage("已存在方式为全盘日期:" + palanDate + "的盘点计划").setErrorCode(400);
|
||||
}
|
||||
}
|
||||
//LinkedHashMap<String,String> linkedHashMap = ( LinkedHashMap<String,String>) in.get("BOXLIST");
|
||||
EventInfo eventInfo = new EventInfoUtil().makeEventInfo("CreateCheckPlan", user, "CreateCheckPlan", "", "");
|
||||
if(null != boxList && boxList.size() > 0 && StringUtils.isNotEmpty(user)){
|
||||
return CheckPlanServiceImpl.CreateCheckPlanListCreate(eventInfo,boxList,palanDate,checkPlanName,moveFlag,siteName);
|
||||
}
|
||||
return AjaxResult.me().setSuccess(true).setErrorCode(200);
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,21 @@ package com.cim.idm.service.Impl;
|
||||
|
||||
import com.cim.idm.exception.GlobalException;
|
||||
import com.cim.idm.framework.data.EventInfo;
|
||||
import com.cim.idm.framework.exception.IDMFrameDBErrorSignal;
|
||||
import com.cim.idm.framework.util.time.TimeStampUtil;
|
||||
import com.cim.idm.mwmsextend.checkplan.CheckPlanServiceProxy;
|
||||
import com.cim.idm.mwmsextend.checkplan.management.data.CheckPlan;
|
||||
import com.cim.idm.mwmsextend.checkplan.management.data.CheckPlanKey;
|
||||
import com.cim.idm.mwmsextend.checkrecord.CheckRecordServiceProxy;
|
||||
import com.cim.idm.mwmsextend.checkrecord.management.data.CheckRecord;
|
||||
import com.cim.idm.mwmsextend.checkrecord.management.data.CheckRecordKey;
|
||||
import com.cim.idm.service.CheckPlanService;
|
||||
import com.cim.idm.utils.AjaxResult;
|
||||
import com.cim.idm.wmspackage.materialpacking.MaterialPackingServiceProxy;
|
||||
import com.cim.idm.wmspackage.materialpacking.management.info.CreateInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class CheckPlanServiceImpl implements CheckPlanService {
|
||||
@ -122,4 +126,81 @@ public class CheckPlanServiceImpl implements CheckPlanService {
|
||||
|
||||
return AjaxResult.me().setSuccess(true).setMessage("添加成功").setErrorCode(1);
|
||||
}
|
||||
public AjaxResult CreateCheckPlanListCreate(
|
||||
EventInfo eventInfo, List<LinkedHashMap<String,String>> boxList,
|
||||
String planDate,String checkPlanName,String moveFlag, String siteName)throws Exception{
|
||||
try {
|
||||
List<CheckRecord> createInfoList = new ArrayList<CheckRecord>();
|
||||
//CheckPlan[] checkPlanArray = new CheckPlan[]();
|
||||
List<CheckPlan> checkPlanList = new ArrayList<>();
|
||||
//String erpFactory = "";
|
||||
//String planDate = "";
|
||||
//String siteName = "";
|
||||
String materialPackingName = "";
|
||||
String sysLocation = "";
|
||||
String planType = "";
|
||||
//String planTypeName = "";
|
||||
//String planCondition = "";
|
||||
String actLocation = "";
|
||||
String erpLocation = "";
|
||||
String materialQuantity = "";
|
||||
String materialSpecName = "";
|
||||
String boxState = "";
|
||||
//String moveFlag = "";
|
||||
String checkPlanState = "";
|
||||
String checkMaterialType = "";
|
||||
String checkPackingType = "";
|
||||
String lastAction = "";
|
||||
String eventTimeKey = TimeStampUtil.getCurrentEventTimeKey();
|
||||
for (int i = 0; i < boxList.size(); i++){
|
||||
LinkedHashMap<String, String> linkedHashMap = boxList.get(i);
|
||||
materialPackingName = linkedHashMap.get("MATERIALPACKINGNAME");
|
||||
sysLocation = linkedHashMap.get("SYSLOCATION");
|
||||
erpLocation = linkedHashMap.get("ERPLOCATION");
|
||||
materialQuantity = linkedHashMap.get("MATERIALQUANTITY");
|
||||
materialSpecName = linkedHashMap.get("MATERIALSPECNAME");
|
||||
lastAction = linkedHashMap.get("LASTACTION");
|
||||
boxState = linkedHashMap.get("BOXSTATE");
|
||||
planType = linkedHashMap.get("PLANTYPE");
|
||||
if (materialPackingName != null)
|
||||
{
|
||||
CheckPlan checkPlan = new CheckPlan();
|
||||
CheckPlanKey checkPlanKey = new CheckPlanKey();
|
||||
checkPlanKey.setPlanDate(planDate);
|
||||
checkPlanKey.setCheckPlanName(checkPlanName);
|
||||
checkPlanKey.setSiteName(siteName);
|
||||
checkPlanKey.setMaterialPackingName(materialPackingName);
|
||||
checkPlan.setKey(checkPlanKey);
|
||||
checkPlan.setPlanType(planType);
|
||||
checkPlan.setPlanTypeName(planType);
|
||||
checkPlan.setSysLocation(sysLocation);
|
||||
checkPlan.setCheckPlanState("Created");
|
||||
checkPlan.setLastAction(lastAction);
|
||||
checkPlan.setMaterialQuantity(Float.parseFloat(materialQuantity));
|
||||
checkPlan.setMaterialSpecName(materialSpecName);
|
||||
checkPlan.setErpLocation(erpLocation);
|
||||
checkPlan.setBoxState(boxState);
|
||||
checkPlan.setMoveFlag(moveFlag);
|
||||
checkPlan.setcheckMPackingType("");
|
||||
checkPlan.setcheckMaterialType("");
|
||||
checkPlan.setLastEventName(eventInfo.getEventName());
|
||||
checkPlan.setLastEventUser(eventInfo.getEventUser());
|
||||
checkPlan.setLastEventTime(eventInfo.getEventTime());
|
||||
checkPlan.setLastEventComment(eventInfo.getEventComment());
|
||||
checkPlan.setLastEventTimeKey(eventTimeKey);
|
||||
checkPlanList.add(checkPlan);
|
||||
}
|
||||
}
|
||||
if(null != checkPlanList && checkPlanList.size() > 0){
|
||||
CheckPlanServiceProxy.getCheckPlanService().insert(checkPlanList);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
//log.info("插入盘点单表数据失败,更新大数据时失败 ==========> ");
|
||||
e.printStackTrace();
|
||||
return AjaxResult.me().setSuccess(false).setMessage(e.toString()).setResultObj(null).setErrorCode(400);
|
||||
}
|
||||
|
||||
return AjaxResult.me().setSuccess(true).setMessage("盘点计划创建完成").setErrorCode(200);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user