Bladeren bron

fix:优化上有任务接受

wang.sq@aliyun.com 3 weken geleden
bovenliggende
commit
9b4e1feb03

+ 3 - 0
imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/common/impl/DictionaryItemServiceImpl.java

@@ -75,7 +75,10 @@ public class DictionaryItemServiceImpl extends SuperCacheServiceImpl<DictionaryI
 
         typeMap.forEach((key, items) -> {
             ImmutableMap<String, String> itemCodeMap = MapHelper.uniqueIndex(items, DictionaryItem::getCode, DictionaryItem::getName);
+            ImmutableMap<String, String> itemCodeMapDETAILS = MapHelper.uniqueIndex(items, DictionaryItem::getCode, DictionaryItem::getDescribe);
+
             typeCodeNameMap.put(key, itemCodeMap);
+            typeCodeNameMap.put(key+"_DETAILS", itemCodeMapDETAILS);
         });
         return typeCodeNameMap;
     }

+ 27 - 9
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/MesNoticeServiceImpl.java

@@ -46,6 +46,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -203,28 +205,44 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public String addNoticeMore(List<MesNotice> models, boolean isExist) {
+    public String addNoticeMore(List<MesNotice> models, boolean isExist){
         log.info("==============新增notice数据开始====================={}", JSONObject.toJSONString(models));
 
         StringBuffer existMsg = new StringBuffer();
         List<MesNotice> needAddMesNotice = new ArrayList<>();
         List<MesNotice> needUpdateMesNotice = new ArrayList<>();
-
         for (MesNotice model : models) {
-            MesNotice mesNotice = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getCheckPar, model.getCheckPar()));
-            if (mesNotice == null) {
+            MesNotice mesNotice = null;
+            List<MesNotice> mesNotices = baseMapper.selectList(Wraps.<MesNotice>lbQ().likeRight(MesNotice::getCheckPar, model.getCheckPar()).orderByDesc(MesNotice::getCreateTime));
+
+            if (mesNotices.isEmpty()) {
                 MesNotice newModel = new MesNotice();
                 BeanUtils.copyProperties(model, newModel);
                 needAddMesNotice.add(newModel);
             } else if (isExist) {
-                if ("1".equals(mesNotice.getStatus())) {
-                    model.setId(mesNotice.getId());
-                    existMsg.append("\n此订单已存在:" + model.getOrderNo());
-                } else {
-                    existMsg.append("\n此订单已存在:" + model.getOrderNo());
+                mesNotice = mesNotices.get(0);
+                // 判断时间是否大于半小时,是的话可以新增,否则不允许
+                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                String startTime = mesNotices.get(0).getCreateTime().format(formatter);
+                long  timeDifference = new Date().getTime() - DateUtil.stringToDate(startTime).getTime();
+                long diffMinute = timeDifference / 1000 / 60;
+                if(diffMinute>30){// 超过半小时可以进行重新接受
+                    MesNotice newModel = new MesNotice();
+                    BeanUtils.copyProperties(model, newModel);
+                    newModel.setCheckPar(newModel.getCheckPar()+"&"+(mesNotices.size()));
+                    newModel.setOrderNo(newModel.getOrderNo()+"/repeat_"+(mesNotices.size()));
+                    needAddMesNotice.add(newModel);
+                }else {
+                    if ("1".equals(mesNotice.getStatus())) { //订单未处理,标记为重复推送
+                        model.setId(mesNotice.getId());
+                        existMsg.append("\n此订单已存在:" + model.getOrderNo());
+                    } else {
+                        existMsg.append("\n此订单已存在:" + model.getOrderNo());
+                    }
                 }
             } else {
                 // 以传输的数据为主
+                mesNotice = mesNotices.get(0);
                 model.setId(mesNotice.getId());
                 BeanUtils.copyProperties(model, mesNotice);
                 needUpdateMesNotice.add(mesNotice);

+ 2 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/MesNoticeService.java

@@ -17,6 +17,7 @@ import org.apache.ibatis.annotations.Param;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
+import java.text.ParseException;
 import java.util.List;
 
 
@@ -37,7 +38,7 @@ public interface MesNoticeService extends SuperService<MesNotice> {
      * @param isExist 只有外部推送的时候生效,重复推送,true,其他false
      * @return
      */
-   String addNoticeMore(List<MesNotice> models, boolean isExist);
+   String addNoticeMore(List<MesNotice> models, boolean isExist) throws ParseException;
    boolean addNotice(MesNotice model, double plmenge);
 
 

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/externalApi/MesNoticeMapper.xml

@@ -38,7 +38,7 @@
             m.*
             FROM
             imcs_mes_notice m
-            order by m.create_time desc, m.api_sort asc
+            order by m.api_type ASC, m.create_time desc, m.`status` DESC, m.api_sort asc
         ) s ${ew.customSqlSegment}
     </select>
 

+ 1 - 3
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionReadyCenter/MMeterialMapper.xml

@@ -16,14 +16,12 @@
         <result column="handle_status" jdbcType="VARCHAR" property="handleStatus"/>
         <result column="status" jdbcType="VARCHAR" property="status"/>
         <result column="num" jdbcType="INTEGER" property="num"/>
-        <result column="draw_number" jdbcType="VARCHAR" property="drawNumber"/>
-        <result column="external_meterial_code" jdbcType="VARCHAR" property="externalMeterialCode"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,zone_id,
-        meterial_code, equipment_name, trade_mark, specification, handle_status, status, num, org_id,draw_number,external_meterial_code
+        meterial_code, equipment_name, trade_mark, specification, handle_status, status, num, org_id
     </sql>
 
     <select id="pageList" resultMap="BaseResultMap">

+ 1 - 1
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/MesController.java

@@ -168,7 +168,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
                         ThreeCoordinateDto threeCoordinateDto = JSONObject.parseObject(JSONObject.toJSONString(jsonObject), ThreeCoordinateDto.class);
                         String checkPar = "407109&TASKDISTRIBUTE&QUALITYTASK&"+threeCoordinateDto.getOrderNumber()+"&"+threeCoordinateDto.getProcessCode()+"&"+threeCoordinateDto.getPartOrder();
 
-                        MesNotice mesNotice = MesNotice.builder().orderNo(threeCoordinateDto.getTaskCode()+"_"+threeCoordinateDto.getProcessCode()+"_"+threeCoordinateDto.getPartOrder()).
+                        MesNotice mesNotice = MesNotice.builder().orderNo(threeCoordinateDto.getOrderNumber()+"/"+threeCoordinateDto.getProcessCode()+"/"+threeCoordinateDto.getPartOrder()).
                                 buType("TASKDISTRIBUTE").apiType("QUALITYTASK"). lineCode("407109"). status("1").  userCode(threeCoordinateDto.getUserCode()).
                                 batchNo(threeCoordinateDto.getBatchNo()). source("数字化检测系统"). targetSource("产线管控单元").sumReport("1").
                                 acceptPar(JSONObject.toJSONString(jsonObject)).checkPar(checkPar).build();

+ 1 - 1
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/util/DateUtil.java

@@ -44,7 +44,7 @@ public class DateUtil {
 	public static final Date stringToDate(String date) {
 		Date dt = null;
 		try {
-			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss a");
+			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 			dt = sdf1.parse(date);
 		} catch (ParseException e) {
 			return null;