|
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
@@ -63,6 +64,13 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
|
MouldFileMapper mouldFileMapper;
|
|
|
@Resource
|
|
|
InjectionMoldingMapper injectionMoldingMapper;
|
|
|
+ @Resource
|
|
|
+ MouldHistoryMapper mouldHistoryMapper;
|
|
|
+ @Resource
|
|
|
+ MouldHistoryTimeMapper mouldHistoryTimeMapper;
|
|
|
+ @Resource
|
|
|
+ PacketLossRecordMapper packetLossRecordMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg addAndUpdateMould(Mould mould, User user, Integer dynamicId,InjectionMolding injectionMolding) {
|
|
@@ -577,4 +585,37 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg packageLoss() {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ Date now = new Date();
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:");
|
|
|
+ int housTime = now.getDay()-1;
|
|
|
+ now.setDate(housTime);
|
|
|
+ String lastOpenTime = sdf1.format(now);
|
|
|
+ try {
|
|
|
+ String lastOpenTimeDate = "2019-10-24 23:" + "59:59";
|
|
|
+ List<MouldHistory> mouldHistorys = mouldHistoryMapper.selectListByTimeCondition(lastOpenTimeDate);
|
|
|
+ for (MouldHistory mouldHistory : mouldHistorys) {
|
|
|
+ Integer count = mouldHistoryTimeMapper.selectCount(new QueryWrapper<MouldHistoryTime>().eq("equipment_no", mouldHistory.getEquipmentNo()).lt("history_id", mouldHistory.getId()));
|
|
|
+ System.out.println("count----->"+count+" runCount---"+mouldHistory.getRunCnt());
|
|
|
+ if(!count .equals(mouldHistory.getRunCnt())){
|
|
|
+ PacketLossRecord record = packetLossRecordMapper.selectOne(new QueryWrapper<PacketLossRecord>().eq("equipment_no", mouldHistory.getEquipmentNo()));
|
|
|
+ if(record != null){
|
|
|
+ record.setCount(mouldHistory.getRunCnt()-count);
|
|
|
+ packetLossRecordMapper.updateById(record);
|
|
|
+ }else{
|
|
|
+ PacketLossRecord packRecord = new PacketLossRecord();
|
|
|
+ packRecord.setCount(mouldHistory.getRunCnt()-count);
|
|
|
+ packRecord.setEquipmentNo(mouldHistory.getEquipmentNo());
|
|
|
+ packetLossRecordMapper.insert(packRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|