From c1075c9320c04c2d524ab2918dd89592b075a856 Mon Sep 17 00:00:00 2001 From: dingjie Date: Sat, 23 Dec 2023 14:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E8=B4=AD=E5=85=A5=E5=BA=93=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/base/api}/domain/MaMachineLabel.java | 2 +- .../controller/MaMachineLabelController.java | 2 +- .../base/mapper/MaMachineLabelMapper.java | 2 +- .../base/service/IMaMachineLabelService.java | 4 +- .../impl/MaMachineLabelServiceImpl.java | 2 +- .../mapper/base/MaHouseSetMapper.xml | 4 +- .../mapper/base/MaMachineLabelMapper.xml | 6 +- .../PurchaseMacodeInfoController.java | 17 +--- .../mapper/PurchaseMacodeInfoMapper.java | 5 ++ .../service/IPurchaseMacodeInfoService.java | 3 +- .../impl/PurchaseMacodeInfoServiceImpl.java | 80 ++++++------------- .../material/PurchaseCheckInfoMapper.xml | 2 +- .../material/PurchaseMacodeInfoMapper.xml | 27 ++++++- sgzb-modules/sgzb-system/pom.xml | 2 +- 14 files changed, 70 insertions(+), 88 deletions(-) rename {sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base => sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api}/domain/MaMachineLabel.java (97%) diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/MaMachineLabel.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineLabel.java similarity index 97% rename from sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/MaMachineLabel.java rename to sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineLabel.java index c7d3b3b9..3ce57f8c 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/MaMachineLabel.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaMachineLabel.java @@ -1,4 +1,4 @@ -package com.bonus.sgzb.base.domain; +package com.bonus.sgzb.base.api.domain; import com.bonus.sgzb.common.core.annotation.Excel; import com.bonus.sgzb.common.core.web.domain.BaseEntity; diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineLabelController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineLabelController.java index 023f7e2d..0787dbc7 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineLabelController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineLabelController.java @@ -2,7 +2,7 @@ package com.bonus.sgzb.base.controller; -import com.bonus.sgzb.base.domain.MaMachineLabel; +import com.bonus.sgzb.base.api.domain.MaMachineLabel; import com.bonus.sgzb.base.service.IMaMachineLabelService; import com.bonus.sgzb.common.core.web.controller.BaseController; import com.bonus.sgzb.common.core.web.domain.AjaxResult; diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineLabelMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineLabelMapper.java index efa723e5..fc296693 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineLabelMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineLabelMapper.java @@ -1,6 +1,6 @@ package com.bonus.sgzb.base.mapper; -import com.bonus.sgzb.base.domain.MaMachineLabel; +import com.bonus.sgzb.base.api.domain.MaMachineLabel; import org.apache.ibatis.annotations.Mapper; import java.util.Date; diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/IMaMachineLabelService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/IMaMachineLabelService.java index 8082059e..b26a790b 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/IMaMachineLabelService.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/IMaMachineLabelService.java @@ -1,8 +1,6 @@ package com.bonus.sgzb.base.service; -import com.bonus.sgzb.base.domain.MaMachineLabel; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Service; +import com.bonus.sgzb.base.api.domain.MaMachineLabel; import java.util.List; diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineLabelServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineLabelServiceImpl.java index 2320c25e..f6d0865b 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineLabelServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaMachineLabelServiceImpl.java @@ -1,6 +1,6 @@ package com.bonus.sgzb.base.service.impl; -import com.bonus.sgzb.base.domain.MaMachineLabel; +import com.bonus.sgzb.base.api.domain.MaMachineLabel; import com.bonus.sgzb.base.mapper.MaMachineLabelMapper; import com.bonus.sgzb.base.service.IMaMachineLabelService; import com.bonus.sgzb.common.core.utils.DateUtils; diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaHouseSetMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaHouseSetMapper.xml index df14eb13..4e1fde98 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaHouseSetMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaHouseSetMapper.xml @@ -92,8 +92,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select mt.type_name specificationType, mt1.type_name machineTypeName, mt2.type_name itemType , mm.ma_code maCode, mhs.house_id, mhs.type_id, mhs.ma_id, mhs.num, mhs.status, mhs.dept_id, mhs.del_flag, mhs.create_by, mhs.create_time, mhs.update_by,mhs.update_time,mhs.remark,mhs.company_id - from ma_type mt - left join ma_machine mm on mt.type_id = mm.type_id + from ma_machine mm + left join ma_type mt on mm.type_id = mt.type_id left join ma_type mt1 on mt.parent_id = mt1.type_id left join ma_type mt2 on mt1.parent_id = mt2.type_id left join ma_house_set mhs on mt.type_id = mhs.type_id diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineLabelMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineLabelMapper.xml index 28b40bd5..8c8f1bdd 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineLabelMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineLabelMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -16,7 +16,7 @@ select label_id, label_code, ma_id, is_bind, label_type, company_id from ma_machine_label - select label_id, label_code, ma_id, is_bind, label_type, company_id from ma_machine_label where is_bind ='0' @@ -26,7 +26,7 @@ from ma_machine_label where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{nowDate},'%y%m') - + insert into ma_machine_label label_code, diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java index 0fcee176..6a1e9c37 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java @@ -86,21 +86,6 @@ public class PurchaseMacodeInfoController extends BaseController return purchaseMacodeInfoService.insertPurchaseMacodeInfo(purchaseMacodeInfoList); } - /** - * 生成设备编号 - */ - @ApiOperation(value = "生成设备编号") - @PostMapping("/equipmentNumber") - public AjaxResult generateEquipmentNumber(@RequestBody EquipmentNumberVO equipmentNumberVO) throws Exception { - Long typeId = equipmentNumberVO.getTypeId(); - if (typeId == null) { - throw new Exception("类型typeId为空!"); - } - if (equipmentNumberVO.getCount() == 0) { - throw new Exception("生成数量为0!"); - } - return success(purchaseMacodeInfoService.generateEquipmentNumber(equipmentNumberVO)); - } /** * 修改新购验收编号管理 @@ -112,7 +97,7 @@ public class PurchaseMacodeInfoController extends BaseController } /** - * 修改新购验收编号管理 + * 修改新购验收编号管理,暂时不用 */ @ApiOperation(value = "修改编码管理的入库状态") @PutMapping("/manageStatus") diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseMacodeInfoMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseMacodeInfoMapper.java index 2dcb949d..68fab2fd 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseMacodeInfoMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseMacodeInfoMapper.java @@ -2,6 +2,7 @@ package com.bonus.sgzb.material.mapper; import com.alibaba.fastjson.JSONObject; import com.bonus.sgzb.base.api.domain.MaMachine; +import com.bonus.sgzb.base.api.domain.MaMachineLabel; import com.bonus.sgzb.base.api.domain.MaType; import com.bonus.sgzb.material.domain.MaInputRecord; import com.bonus.sgzb.material.domain.PurchaseMacodeInfo; @@ -102,4 +103,8 @@ public interface PurchaseMacodeInfoMapper { int selectMaCode(String maCode); int updateMacodeByType(PurchaseMacodeInfo purchaseMacodeInfo); + + int selectLableNumByMonth(Date nowDate); + + int insertMaMachineLabel(MaMachineLabel maMachineLabel); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseMacodeInfoService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseMacodeInfoService.java index e069255b..eadb2a3c 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseMacodeInfoService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseMacodeInfoService.java @@ -1,6 +1,7 @@ package com.bonus.sgzb.material.service; import com.alibaba.fastjson.JSONObject; +import com.bonus.sgzb.base.api.domain.MaMachineLabel; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.material.domain.MaInputRecord; import com.bonus.sgzb.material.domain.PurchaseMacodeInfo; @@ -65,7 +66,7 @@ public interface IPurchaseMacodeInfoService */ public int deletePurchaseMacodeInfoByTaskId(Long taskId); - JSONObject generateEquipmentNumber(EquipmentNumberVO equipmentNumberVO); + String generateEquipmentNumber(MaMachineLabel maMachineLabel); int deletePurchaseMacodeInfoById(Long id); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java index 3d04a4d9..c2b3bb23 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java @@ -8,6 +8,7 @@ import java.util.List; import com.alibaba.fastjson.JSONObject; import com.bonus.sgzb.base.api.domain.MaMachine; +import com.bonus.sgzb.base.api.domain.MaMachineLabel; import com.bonus.sgzb.base.api.domain.MaType; import com.bonus.sgzb.base.api.domain.TmTask; import com.bonus.sgzb.common.core.utils.StringUtils; @@ -99,11 +100,15 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService String maCode = purchaseMacodeInfo.getMaCode(); purchaseCheckDetails.setTypeId(typeId); purchaseCheckDetails.setTaskId(purchaseMacodeInfo.getTaskId()); + + MaMachineLabel maLabel = new MaMachineLabel(); + String qrCode = generateEquipmentNumber(maLabel); + if (StringUtils.isNotEmpty(maCode)) { MaMachine maMachine = new MaMachine(); maMachine.setTypeId(typeId); maMachine.setMaStatus("14"); - maMachine.setQrCode(purchaseMacodeInfo.getQrCode()); + maMachine.setQrCode(qrCode); // 设备原厂编号 String fixCode = purchaseMacodeInfo.getFixCode(); if ("0".equals(fixCode)) { @@ -118,16 +123,7 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService maMachine.setCreateBy(SecurityUtils.getUsername()); purchaseMacodeInfoMapper.maMachineAdd(maMachine); } - String qrCode = purchaseMacodeInfo.getQrCode(); - // 二维码存储 - if (StringUtils.isNotEmpty(qrCode)) { - BmQrcodeInfo bmQrcodeInfo = new BmQrcodeInfo(); - bmQrcodeInfo.setTypeId(typeId); - bmQrcodeInfo.setQrCode(qrCode); - bmQrcodeInfo.setTaskId(purchaseMacodeInfo.getTaskId()); - bmQrcodeInfo.setCreateTime(new Date()); - qrcodeInfoMapper.insertBmQrcodeInfo(bmQrcodeInfo); - } + purchaseMacodeInfo.setStatus("0"); purchaseMacodeInfo.setCreateTime(DateUtils.getNowDate()); purchaseMacodeInfoMapper.insertPurchaseMacodeInfo(purchaseMacodeInfo); @@ -215,55 +211,27 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService /** * 生成设备编号 * - * @param equipmentNumberVO 类型id,生成数量 + * @param maMachineLabel 类型id,生成数量 * @return 编码结果 */ @Override - public JSONObject generateEquipmentNumber(EquipmentNumberVO equipmentNumberVO) { - Long typeId = equipmentNumberVO.getTypeId(); - SimpleDateFormat sdf = new SimpleDateFormat("yyMM"); + public String generateEquipmentNumber(MaMachineLabel maMachineLabel) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date nowDate = DateUtils.getNowDate(); - String format = sdf.format(nowDate); - - JSONObject jsonObject = purchaseMacodeInfoMapper.getTypeByTypeId(typeId); - String typeCode = jsonObject.getString("modelCode"); - String specsCode = jsonObject.getString("specsCode"); - //序列号 - int count = purchaseMacodeInfoMapper.getSerialNumber(typeId, nowDate) + 1; - List list = new ArrayList<>(); - List codeList = new ArrayList<>(); - for (int i = 0; i < equipmentNumberVO.getCount(); i++) { - int i1 = count + i; - // 编码规则 - String codingRule = "NSJJ" + specsCode + format + typeCode; - String codeNum = ""; - String code = format; - String code1 = format; - if (i1 > 9 && i1 < 100) { - codeNum = "-00" + i1; - code1 = "-00" + i1; - } else if (i1 > 99 && i1 < 1000) { - codeNum = "-0" + i1; - code1 = "-0" + i1; - } else { - codeNum = "-000" + i1; - code1 = "-000" + i1; - } - codingRule = codingRule + codeNum; - code = code + code1; - // 二维码 - int i2 = purchaseMacodeInfoMapper.selectMachineByMaCode(codingRule); - if (i2 <= 0) { - list.add(codingRule); - } - codeList.add(code); + String format = dateFormat.format(nowDate); + int lableNum = purchaseMacodeInfoMapper.selectLableNumByMonth(nowDate) + 1; + String code=""; + if (lableNum>9 && lableNum<100){ + code = format + "-00" + lableNum; + }else if (lableNum>99 && lableNum<1000){ + code = format + "-0" + lableNum; + }else { + code = format + "-000" + lableNum; } - - JSONObject result = new JSONObject(); - result.put("equipmentNum", list); - result.put("twoDimensionalCode", codeList); - - return result; + maMachineLabel.setIsBind("0"); + maMachineLabel.setLabelCode(code); + purchaseMacodeInfoMapper.insertMaMachineLabel(maMachineLabel); + return code; } /** @@ -278,7 +246,7 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService } /** - * 修改编码管理的入库状态 + * 修改编码管理的入库状态,暂时不用 * * @param maInputVO 入库信息 * @return 结果 diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml index ba6a973d..7c64189a 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml @@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join tm_task tk on pci.task_id = tk.task_id left join (select id,name from sys_dic where p_id = 23) dict on tk.task_status = dict.id left join sys_user su on pci.purchaser = su.user_id - where task_type = 23 and tk.task_status in (24,25,26,27) + where task_type = 23 and tk.code = #{code} and pci.purchase_time = #{purchaseTime} and pci.arrival_time = #{arrivalTime} diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml index 3c1061a4..b5cbd948 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml @@ -235,6 +235,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{companyId}, + + insert into ma_machine_label + + label_code, + ma_id, + is_bind, + label_type, + company_id, + create_time + + + #{labelCode}, + #{maId}, + #{isBind}, + #{labelType}, + #{companyId}, + now() + + select pcd.production_time productionTime,mt.type_name specificationType, mt1.type_name typeName, pmi.ma_code maCode, mm.assets_code assetsCode ,pmi.fix_code fixCode,pcd.type_id typeId,pcd.task_id taskId, mt.code specsCode,mt1.code typeCode, - if(pmi.ma_code is null, if(pcd.status != 4, 0 , 1), pmi.status) status, + if(pmi.ma_code is null, if(pcd.status != 4, 0 , 1), pmi.status) status,mm.qr_code qrCode, if(pmi.ma_code is not null,1,pcd.check_num) checkNum from purchase_check_details pcd left join purchase_macode_info pmi on pmi.task_id = pcd.task_id and pmi.type_id = pcd.type_id @@ -268,10 +287,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join ma_type mt on pcd.type_id = mt.type_id left join ma_type mt1 on mt.parent_id = mt1.type_id where pcd.task_id = #{taskId} + order by status + update ma_type set num = #{num} where type_id = #{typeId} diff --git a/sgzb-modules/sgzb-system/pom.xml b/sgzb-modules/sgzb-system/pom.xml index 163e457a..ec29e566 100644 --- a/sgzb-modules/sgzb-system/pom.xml +++ b/sgzb-modules/sgzb-system/pom.xml @@ -123,5 +123,5 @@ - + \ No newline at end of file