|
@@ -1,52 +1,208 @@
|
|
|
package org.jeecg.modules.openApi.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.jeecg.modules.openApi.entity.SubcontractingOrder;
|
|
|
+import org.jeecg.modules.openApi.mapper.PurchaseWarehousingMapper;
|
|
|
import org.jeecg.modules.openApi.mapper.SubcontractingOrderMapper;
|
|
|
import org.jeecg.modules.openApi.service.SubcontractingOrderService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import static org.apache.commons.lang3.RegExUtils.replaceFirst;
|
|
|
|
|
|
@Service
|
|
|
public class SubcontractingOrderImpl extends ServiceImpl<SubcontractingOrderMapper, SubcontractingOrder> implements SubcontractingOrderService {
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private PurchaseWarehousingMapper purchaseWarehousingMapper;
|
|
|
@Autowired
|
|
|
private SubcontractingOrderMapper subcontractingOrderMapper;
|
|
|
|
|
|
+
|
|
|
+ * 调用存储过程 获取下一个编码
|
|
|
+ * @param StuNo 单据类型 24:入库单
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
@DS("multi-one")
|
|
|
- public List<SubcontractingOrder> selectOrderByCode(String code,String MoDetailsID){
|
|
|
- return subcontractingOrderMapper.selectOrderByCode(code,MoDetailsID);
|
|
|
+ public String callGetMaxCode(String StuNo) {
|
|
|
+ int num = subcontractingOrderMapper.callGetMaxCode(StuNo);
|
|
|
+ if(num == 0){
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if(num < 1000000000){
|
|
|
+ num = num + 1000000000;
|
|
|
+ }else{
|
|
|
+ return String.valueOf(num);
|
|
|
+ }
|
|
|
+ String code = String.valueOf(num);
|
|
|
+ code = replaceFirst(code, "1", "0");
|
|
|
+
|
|
|
+ return code;
|
|
|
}
|
|
|
|
|
|
- public String saveWarehousing(JSONArray json){
|
|
|
|
|
|
- for(int i=0;i<json.size();i++){
|
|
|
- JSONObject jsonObject=json.getJSONObject(i);
|
|
|
-
|
|
|
- if(jsonObject.get("cAccId") != null){
|
|
|
- String cAccId=jsonObject.get("cAccId").toString();
|
|
|
+
|
|
|
+ * 调用存储过程 获取下一个主键(包含主子表)
|
|
|
+ * @param StuNo rd:入库单
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
+ @DS("multi-one")
|
|
|
+ public Map<String,Integer> callGetUAMaxPK(String StuNo) {
|
|
|
+ Map<String,Integer> map = subcontractingOrderMapper.callGetUAMaxPK(StuNo);
|
|
|
+ Map<String,Integer> map1 = new HashMap<>();
|
|
|
+
|
|
|
+ if(map.get("iFatherId") != null){
|
|
|
+ if(map.get("iFatherId") >= 1000000000){
|
|
|
+ map1.put("iFatherId",map.get("iFatherId"));
|
|
|
}else{
|
|
|
- throw new RuntimeException("cAccId不能为空,或不合法");
|
|
|
+ map1.put("iFatherId",map.get("iFatherId")+1000000000);
|
|
|
}
|
|
|
- if(jsonObject.get("cAccId") != null){
|
|
|
- String bredvouch=jsonObject.get("bredvouch").toString();
|
|
|
+ }
|
|
|
+ if(map.get("iChildId") != null){
|
|
|
+ if(map.get("iChildId") >= 1000000000){
|
|
|
+ map1.put("iChildId",map.get("iChildId"));
|
|
|
+ }else{
|
|
|
+ map1.put("iChildId",map.get("iChildId")+1000000000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map1;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DS("multi-one")
|
|
|
+ public List<SubcontractingOrder> selectOrderByCodeOne(String code,String MoDetailsID){
|
|
|
+ return subcontractingOrderMapper.selectOrderByCode(code,MoDetailsID);
|
|
|
+ }
|
|
|
+ @DS("multi-two")
|
|
|
+ public List<SubcontractingOrder> selectOrderByCodeTwo(String code,String MoDetailsID){
|
|
|
+ return subcontractingOrderMapper.selectOrderByCode(code,MoDetailsID);
|
|
|
+ }
|
|
|
+ @DS("multi-three")
|
|
|
+ public List<SubcontractingOrder> selectOrderByCodeThree(String code,String MoDetailsID){
|
|
|
+ return subcontractingOrderMapper.selectOrderByCode(code,MoDetailsID);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DS("multi-one")
|
|
|
+ @Override
|
|
|
+ public String saveWarehousing(List<Map<String,Object>> mapList){
|
|
|
+
|
|
|
+ for(Map<String,Object> map:mapList){
|
|
|
+
|
|
|
+ Map<String,Integer> pkMap = this.callGetUAMaxPK("rd");
|
|
|
+ map.put("ID",pkMap.get("iFatherId"));
|
|
|
+
|
|
|
+ String cCode = this.callGetMaxCode("24");
|
|
|
+ if(cCode!=null){
|
|
|
+ map.put("cCode",cCode);
|
|
|
}else{
|
|
|
- throw new RuntimeException("bredvouch不能为空,或不合法");
|
|
|
+ throw new RuntimeException("获取入库单号失败");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if(map.get("cVouchType").toString().equals("0")){
|
|
|
+ map.put("cVouchType",0);
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("cVouchType:只能进行采购入库(0)");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(map.get("cRdCode").toString().equals("委外入库")){
|
|
|
+
|
|
|
+ map.put("cRdCode",12);
|
|
|
+ map.put("cPTCode",02);
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("入库类别:只能进行委外入库");
|
|
|
+ }
|
|
|
+ map.put("dDate",new Date());
|
|
|
+ if(map.get("cWhCode") == null){
|
|
|
+ throw new RuntimeException("cWhCode为空");
|
|
|
+ }
|
|
|
+ if(map.get("cOrderCode") == null){
|
|
|
+ throw new RuntimeException("委外订单号为空");
|
|
|
+ }
|
|
|
+ if(map.get("cBusType") == null){
|
|
|
+ map.put("cBusType","委外加工");
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+ subcontractingOrderMapper.saveRdRecord01One(map);
|
|
|
+
|
|
|
+ if(map.get("item") != null && !map.get("item").equals("")){
|
|
|
+ List<Map<String,Object>> itemList=(List<Map<String,Object>>)map.get("item");
|
|
|
+ Integer rowId=0;
|
|
|
+ for(Map<String,Object> itemMap:itemList){
|
|
|
+ rowId++;
|
|
|
+
|
|
|
+ Map<String,Integer> pkMapChild = this.callGetUAMaxPK("rd");
|
|
|
+ itemMap.put("AutoID",pkMapChild.get("iChildId"));
|
|
|
+
|
|
|
+ itemMap.put("ID",map.get("ID"));
|
|
|
+
|
|
|
+ itemMap.put("irowno",rowId);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(itemMap.get("cInvCode") == null){
|
|
|
+ throw new RuntimeException("cInvCode为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(itemMap.get("iQuantity") == null){
|
|
|
+ throw new RuntimeException("iQuantity为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(itemMap.get("unit") == null){
|
|
|
+ throw new RuntimeException("unit为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(itemMap.get("cBatch") == null){
|
|
|
+ throw new RuntimeException("cBatch为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(itemMap.get("color") == null){
|
|
|
+ throw new RuntimeException("color为空");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ itemMap.put("iordercode",map.get("cOrderCode"));
|
|
|
+
|
|
|
+
|
|
|
+ if(itemMap.get("num") == null){
|
|
|
+ throw new RuntimeException("num为空");
|
|
|
+ }
|
|
|
+ subcontractingOrderMapper.saveRdRecord01One(itemMap);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("item为空");
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
return "true";
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|