diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/controller/AbnormalPlanController.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/controller/AbnormalPlanController.java new file mode 100644 index 00000000..b9a683ba --- /dev/null +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/controller/AbnormalPlanController.java @@ -0,0 +1,130 @@ +package com.foreverwin.mesnac.anomaly.controller; + +import com.foreverwin.modular.core.util.R; +import com.foreverwin.modular.core.util.FrontPage; +import com.foreverwin.modular.core.util.CommonMethods; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import com.foreverwin.mesnac.anomaly.service.AbnormalPlanService; +import com.foreverwin.mesnac.anomaly.model.AbnormalPlan; +import java.util.List; + +/** + * + * @author zjw + * @since 2021-08-07 + */ +@RestController +@RequestMapping("/Z-ABNORMAL-PLAN") +public class AbnormalPlanController { + + @Autowired + public AbnormalPlanService abnormalPlanService; + + /** + * 根据id查询 + * + * @param id 主键 + * @return + */ + @ResponseBody + @GetMapping("/{id:.+}") + public R getAbnormalPlanById(@PathVariable String id) { + return R.ok( abnormalPlanService.getById(id)); + } + + /** + * 查询所有数据 + * + * @return + */ + @ResponseBody + @GetMapping("") + public R getAbnormalPlanList(AbnormalPlan abnormalPlan){ + List result; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(abnormalPlan); + result = abnormalPlanService.list(queryWrapper); + return R.ok(result); + } + + /** + * 分页查询数据 + * + * @param frontPage 分页信息 + * @return + */ + @ResponseBody + @GetMapping("/page") + public R page(FrontPage frontPage, AbnormalPlan abnormalPlan){ + IPage result; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(abnormalPlan); + if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) { + //TODO modify global query + queryWrapper.lambda().and(wrapper -> wrapper + .like(AbnormalPlan::getHandle, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getSite, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getAbnormalBillBo, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getStatus, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getWorkCenter, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getAbnormalMethod, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getShopOrder, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getResrce, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getItemBo, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getProcessor, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getClosedUser, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getCreatedUser, frontPage.getGlobalQuery()) + .or().like(AbnormalPlan::getModifiedUser, frontPage.getGlobalQuery()) + ); + } + result = abnormalPlanService.page(frontPage.getPagePlus(), queryWrapper); + return R.ok(result); + } + + /** + * 新增 + * @param abnormalPlan 传递的实体 + * @return null 失败 实体成功 + */ + @PostMapping + public R save(@RequestBody AbnormalPlan abnormalPlan) { + return R.ok(abnormalPlanService.save(abnormalPlan)); + } + + /** + * 修改 + * @param abnormalPlan 传递的实体 + * @return null 失败 实体成功 + */ + @PutMapping + public R updateById(@RequestBody AbnormalPlan abnormalPlan) { + return R.ok(abnormalPlanService.updateById(abnormalPlan)); + } + + /** + * 根据id删除对象 + * @param id 实体ID + * @return 0 失败 1 成功 + */ + @ResponseBody + @RequestMapping(method = RequestMethod.DELETE, value = "/{id:.+}") + public R removeById(@PathVariable("id") String id){ + return R.ok(abnormalPlanService.removeById(id)); + } + + /** + * 批量删除对象 + * @param ids 实体集合ID + * @return 0 失败 1 成功 + */ + @ResponseBody + @RequestMapping(method = RequestMethod.POST, value = "/delete-batch") + public R removeByIds(List ids){ + return R.ok(abnormalPlanService.removeByIds(ids)); + } +} \ No newline at end of file diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/AbnormalPlanMapper.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/AbnormalPlanMapper.java new file mode 100644 index 00000000..503ae4d3 --- /dev/null +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/AbnormalPlanMapper.java @@ -0,0 +1,18 @@ +package com.foreverwin.mesnac.anomaly.mapper; + +import com.foreverwin.mesnac.anomaly.model.AbnormalPlan; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * Mapper 接口 + *

+ * + * @author zjw + * @since 2021-08-07 + */ +@Repository +public interface AbnormalPlanMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/model/AbnormalPlan.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/model/AbnormalPlan.java new file mode 100644 index 00000000..d718d623 --- /dev/null +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/model/AbnormalPlan.java @@ -0,0 +1,329 @@ +package com.foreverwin.mesnac.anomaly.model; + +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import com.baomidou.mybatisplus.annotation.IdType; + +/** + *

+ * + *

+ * + * @author zjw + * @since 2021-08-07 + */ + +@TableName("Z_ABNORMAL_PLAN") + +public class AbnormalPlan extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "HANDLE", type = IdType.INPUT) + private String handle; + /** + * 站点 + */ + @TableField("SITE") + private String site; + /** + * 异常单号 + */ + @TableField("ABNORMAL_BILL_BO") + private String abnormalBillBo; + /** + * 状态 + */ + @TableField("STATUS") + private String status; + /** + * 车间 + */ + @TableField("WORK_CENTER") + private String workCenter; + /** + * 异常方案 + */ + @TableField("ABNORMAL_METHOD") + private String abnormalMethod; + /** + * 工单 + */ + @TableField("SHOP_ORDER") + private String shopOrder; + /** + * 设备 + */ + @TableField("RESRCE") + private String resrce; + /** + * 物料编号 + */ + @TableField("ITEM_BO") + private String itemBo; + /** + * 异常数量 + */ + @TableField("QTY") + private Long qty; + /** + * 处理人 + */ + @TableField("PROCESSOR") + private String processor; + /** + * 处理时间 + */ + @TableField("PROCESS_DATE_TIME") + private LocalDateTime processDateTime; + /** + * 闭环人员 + */ + @TableField("CLOSED_USER") + private String closedUser; + /** + * 闭环时间 + */ + @TableField("CLOSED_DATE_TIME") + private LocalDateTime closedDateTime; + /** + * 创建人 + */ + @TableField("CREATED_USER") + private String createdUser; + /** + * 创建时间 + */ + @TableField("CREATED_DATE_TIME") + private LocalDateTime createdDateTime; + /** + * 修改人 + */ + @TableField("MODIFIED_USER") + private String modifiedUser; + /** + * 修改日期 + */ + @TableField("MODIFIED_DATE_TIME") + private LocalDateTime modifiedDateTime; + + + public String getHandle() { + return handle; + } + + public void setHandle(String handle) { + this.handle = handle; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getAbnormalBillBo() { + return abnormalBillBo; + } + + public void setAbnormalBillBo(String abnormalBillBo) { + this.abnormalBillBo = abnormalBillBo; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getWorkCenter() { + return workCenter; + } + + public void setWorkCenter(String workCenter) { + this.workCenter = workCenter; + } + + public String getAbnormalMethod() { + return abnormalMethod; + } + + public void setAbnormalMethod(String abnormalMethod) { + this.abnormalMethod = abnormalMethod; + } + + public String getShopOrder() { + return shopOrder; + } + + public void setShopOrder(String shopOrder) { + this.shopOrder = shopOrder; + } + + public String getResrce() { + return resrce; + } + + public void setResrce(String resrce) { + this.resrce = resrce; + } + + public String getItemBo() { + return itemBo; + } + + public void setItemBo(String itemBo) { + this.itemBo = itemBo; + } + + public Long getQty() { + return qty; + } + + public void setQty(Long qty) { + this.qty = qty; + } + + public String getProcessor() { + return processor; + } + + public void setProcessor(String processor) { + this.processor = processor; + } + + public LocalDateTime getProcessDateTime() { + return processDateTime; + } + + public void setProcessDateTime(LocalDateTime processDateTime) { + this.processDateTime = processDateTime; + } + + public String getClosedUser() { + return closedUser; + } + + public void setClosedUser(String closedUser) { + this.closedUser = closedUser; + } + + public LocalDateTime getClosedDateTime() { + return closedDateTime; + } + + public void setClosedDateTime(LocalDateTime closedDateTime) { + this.closedDateTime = closedDateTime; + } + + public String getCreatedUser() { + return createdUser; + } + + public void setCreatedUser(String createdUser) { + this.createdUser = createdUser; + } + + public LocalDateTime getCreatedDateTime() { + return createdDateTime; + } + + public void setCreatedDateTime(LocalDateTime createdDateTime) { + this.createdDateTime = createdDateTime; + } + + public String getModifiedUser() { + return modifiedUser; + } + + public void setModifiedUser(String modifiedUser) { + this.modifiedUser = modifiedUser; + } + + public LocalDateTime getModifiedDateTime() { + return modifiedDateTime; + } + + public void setModifiedDateTime(LocalDateTime modifiedDateTime) { + this.modifiedDateTime = modifiedDateTime; + } + +public static final String HANDLE = "HANDLE"; + +public static final String SITE = "SITE"; + +public static final String ABNORMAL_BILL_BO = "ABNORMAL_BILL_BO"; + +public static final String STATUS = "STATUS"; + +public static final String WORK_CENTER = "WORK_CENTER"; + +public static final String ABNORMAL_METHOD = "ABNORMAL_METHOD"; + +public static final String SHOP_ORDER = "SHOP_ORDER"; + +public static final String RESRCE = "RESRCE"; + +public static final String ITEM_BO = "ITEM_BO"; + +public static final String QTY = "QTY"; + +public static final String PROCESSOR = "PROCESSOR"; + +public static final String PROCESS_DATE_TIME = "PROCESS_DATE_TIME"; + +public static final String CLOSED_USER = "CLOSED_USER"; + +public static final String CLOSED_DATE_TIME = "CLOSED_DATE_TIME"; + +public static final String CREATED_USER = "CREATED_USER"; + +public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME"; + +public static final String MODIFIED_USER = "MODIFIED_USER"; + +public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME"; + + + @Override + protected Serializable pkVal() { + return this.handle; + } + + @Override + public String toString() { + return "AbnormalPlan{" + + "handle = " + handle + + ", site = " + site + + ", abnormalBillBo = " + abnormalBillBo + + ", status = " + status + + ", workCenter = " + workCenter + + ", abnormalMethod = " + abnormalMethod + + ", shopOrder = " + shopOrder + + ", resrce = " + resrce + + ", itemBo = " + itemBo + + ", qty = " + qty + + ", processor = " + processor + + ", processDateTime = " + processDateTime + + ", closedUser = " + closedUser + + ", closedDateTime = " + closedDateTime + + ", createdUser = " + createdUser + + ", createdDateTime = " + createdDateTime + + ", modifiedUser = " + modifiedUser + + ", modifiedDateTime = " + modifiedDateTime + + "}"; + } +} \ No newline at end of file diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/AbnormalPlanService.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/AbnormalPlanService.java new file mode 100644 index 00000000..401eff8b --- /dev/null +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/AbnormalPlanService.java @@ -0,0 +1,32 @@ +package com.foreverwin.mesnac.anomaly.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.foreverwin.mesnac.anomaly.dto.AbnormalBillDisposeDto; +import com.foreverwin.mesnac.anomaly.model.AbnormalPlan; +import com.foreverwin.modular.core.util.FrontPage; + +import java.time.LocalDateTime; +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author zjw + * @since 2021-08-07 + */ +public interface AbnormalPlanService extends IService { + + /** + * 分页查询 + * @param frontPage + * @return + */ + IPage selectPage(FrontPage frontPage, AbnormalPlan abnormalPlan); + + List selectList(AbnormalPlan abnormalPlan); + + void saveAbnormalPlan(AbnormalBillDisposeDto abnormalBillDisposeDto, LocalDateTime now); +} \ No newline at end of file diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java index 8978e5da..f06e58e2 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java @@ -142,6 +142,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl selectPage(FrontPage frontPage, AbnormalBill abnormalBill) { @@ -359,7 +362,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl hashMap = new HashMap<>(); @@ -776,7 +785,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl + * 服务实现类 + *

+ * + * @author zjw + * @since 2021-08-07 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class AbnormalPlanServiceImpl extends ServiceImpl implements AbnormalPlanService { + + + @Autowired + private AbnormalPlanMapper abnormalPlanMapper; + + @Override + public IPage selectPage(FrontPage frontPage, AbnormalPlan abnormalPlan) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(abnormalPlan); + return super.page(frontPage.getPagePlus(), queryWrapper); + } + + @Override + public List selectList(AbnormalPlan abnormalPlan) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(abnormalPlan); + return super.list(queryWrapper); + } + + @Override + public void saveAbnormalPlan(AbnormalBillDisposeDto abnormalBillDisposeDto,LocalDateTime now) { + String site = CommonMethods.getSite(); + AbnormalPlan abnormalPlan = new AbnormalPlan(); + String user = CommonMethods.getUser(); + //设置主键 + abnormalPlan.setHandle(HandleEnum.ABNORMAL_PLAN.getHandle(site,abnormalBillDisposeDto.getAbnormalNo())); + abnormalPlan.setSite(site); + abnormalPlan.setAbnormalBillBo(HandleEnum.ABNORMAL_BILL.getHandle(site,abnormalBillDisposeDto.getAbnormalNo())); + abnormalPlan.setStatus(Constants.UNTREATED);//未处理 + abnormalPlan.setWorkCenter(abnormalBillDisposeDto.getWorkCenter()); + abnormalPlan.setAbnormalMethod(abnormalBillDisposeDto.getAbnormalMethod()); + abnormalPlan.setShopOrder(abnormalBillDisposeDto.getShopOrder()); + abnormalPlan.setResrce(abnormalBillDisposeDto.getResrce()); + abnormalPlan.setItemBo(abnormalBillDisposeDto.getItemBo()); + abnormalPlan.setQty(Long.parseLong(abnormalBillDisposeDto.getNcQty())); + //没有处理人和处理时间 +// abnormalPlan.setProcessor(); + abnormalPlan.setClosedUser(user); + abnormalPlan.setClosedDateTime(now); + abnormalPlan.setCreatedUser(user); + abnormalPlan.setCreatedDateTime(now); + abnormalPlan.setModifiedUser(user); + abnormalPlan.setModifiedDateTime(now); + this.saveOrUpdate(abnormalPlan); + } + +} \ No newline at end of file diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AnomalyJobServiceImpl.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AnomalyJobServiceImpl.java index 38e29b7d..72df1bc8 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AnomalyJobServiceImpl.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AnomalyJobServiceImpl.java @@ -129,7 +129,7 @@ public class AnomalyJobServiceImpl implements AnomalyJobService { activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent()); // } messageService.saveOrUpdate(abnormalMessage); - messageService.saveOrUpdate(_abnormalMessage); + // messageService.saveOrUpdate(_abnormalMessage); } } } diff --git a/anomaly/src/main/resources/mapper/AbnormalPlanMapper.xml b/anomaly/src/main/resources/mapper/AbnormalPlanMapper.xml new file mode 100644 index 00000000..40c3bd1b --- /dev/null +++ b/anomaly/src/main/resources/mapper/AbnormalPlanMapper.xml @@ -0,0 +1,530 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HANDLE, SITE, ABNORMAL_BILL_BO, STATUS, WORK_CENTER, ABNORMAL_METHOD, SHOP_ORDER, RESRCE, ITEM_BO, QTY, PROCESSOR, PROCESS_DATE_TIME, CLOSED_USER, CLOSED_DATE_TIME, CREATED_USER, CREATED_DATE_TIME, MODIFIED_USER, MODIFIED_DATE_TIME + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO Z_ABNORMAL_PLAN + + HANDLE, + SITE, + ABNORMAL_BILL_BO, + STATUS, + WORK_CENTER, + ABNORMAL_METHOD, + SHOP_ORDER, + RESRCE, + ITEM_BO, + QTY, + PROCESSOR, + PROCESS_DATE_TIME, + CLOSED_USER, + CLOSED_DATE_TIME, + CREATED_USER, + CREATED_DATE_TIME, + MODIFIED_USER, + MODIFIED_DATE_TIME, + VALUES + + #{handle}, + #{site}, + #{abnormalBillBo}, + #{status}, + #{workCenter}, + #{abnormalMethod}, + #{shopOrder}, + #{resrce}, + #{itemBo}, + #{qty}, + #{processor}, + #{processDateTime}, + #{closedUser}, + #{closedDateTime}, + #{createdUser}, + #{createdDateTime}, + #{modifiedUser}, + #{modifiedDateTime}, + + + + + INSERT INTO Z_ABNORMAL_PLAN + + + VALUES + + #{handle}, + #{site}, + #{abnormalBillBo}, + #{status}, + #{workCenter}, + #{abnormalMethod}, + #{shopOrder}, + #{resrce}, + #{itemBo}, + #{qty}, + #{processor}, + #{processDateTime}, + #{closedUser}, + #{closedDateTime}, + #{createdUser}, + #{createdDateTime}, + #{modifiedUser}, + #{modifiedDateTime}, + + + + + + UPDATE Z_ABNORMAL_PLAN + SITE=#{et.site}, + ABNORMAL_BILL_BO=#{et.abnormalBillBo}, + STATUS=#{et.status}, + WORK_CENTER=#{et.workCenter}, + ABNORMAL_METHOD=#{et.abnormalMethod}, + SHOP_ORDER=#{et.shopOrder}, + RESRCE=#{et.resrce}, + ITEM_BO=#{et.itemBo}, + QTY=#{et.qty}, + PROCESSOR=#{et.processor}, + PROCESS_DATE_TIME=#{et.processDateTime}, + CLOSED_USER=#{et.closedUser}, + CLOSED_DATE_TIME=#{et.closedDateTime}, + CREATED_USER=#{et.createdUser}, + CREATED_DATE_TIME=#{et.createdDateTime}, + MODIFIED_USER=#{et.modifiedUser}, + MODIFIED_DATE_TIME=#{et.modifiedDateTime}, + WHERE HANDLE=#{et.handle} and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL} + + + + + UPDATE Z_ABNORMAL_PLAN + SITE=#{et.site}, + ABNORMAL_BILL_BO=#{et.abnormalBillBo}, + STATUS=#{et.status}, + WORK_CENTER=#{et.workCenter}, + ABNORMAL_METHOD=#{et.abnormalMethod}, + SHOP_ORDER=#{et.shopOrder}, + RESRCE=#{et.resrce}, + ITEM_BO=#{et.itemBo}, + QTY=#{et.qty}, + PROCESSOR=#{et.processor}, + PROCESS_DATE_TIME=#{et.processDateTime}, + CLOSED_USER=#{et.closedUser}, + CLOSED_DATE_TIME=#{et.closedDateTime}, + CREATED_USER=#{et.createdUser}, + CREATED_DATE_TIME=#{et.createdDateTime}, + MODIFIED_USER=#{et.modifiedUser}, + MODIFIED_DATE_TIME=#{et.modifiedDateTime}, + WHERE HANDLE=#{et.handle} and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL} + + + + + UPDATE Z_ABNORMAL_PLAN + SITE=#{et.site}, + ABNORMAL_BILL_BO=#{et.abnormalBillBo}, + STATUS=#{et.status}, + WORK_CENTER=#{et.workCenter}, + ABNORMAL_METHOD=#{et.abnormalMethod}, + SHOP_ORDER=#{et.shopOrder}, + RESRCE=#{et.resrce}, + ITEM_BO=#{et.itemBo}, + QTY=#{et.qty}, + PROCESSOR=#{et.processor}, + PROCESS_DATE_TIME=#{et.processDateTime}, + CLOSED_USER=#{et.closedUser}, + CLOSED_DATE_TIME=#{et.closedDateTime}, + CREATED_USER=#{et.createdUser}, + CREATED_DATE_TIME=#{et.createdDateTime}, + MODIFIED_USER=#{et.modifiedUser}, + MODIFIED_DATE_TIME=#{et.modifiedDateTime}, + + + + + HANDLE=#{ew.entity.handle} + AND SITE=#{ew.entity.site} + AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo} + AND STATUS=#{ew.entity.status} + AND WORK_CENTER=#{ew.entity.workCenter} + AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod} + AND SHOP_ORDER=#{ew.entity.shopOrder} + AND RESRCE=#{ew.entity.resrce} + AND ITEM_BO=#{ew.entity.itemBo} + AND QTY=#{ew.entity.qty} + AND PROCESSOR=#{ew.entity.processor} + AND PROCESS_DATE_TIME=#{ew.entity.processDateTime} + AND CLOSED_USER=#{ew.entity.closedUser} + AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime} + AND CREATED_USER=#{ew.entity.createdUser} + AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} + AND MODIFIED_USER=#{ew.entity.modifiedUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} + + + ${ew.sqlSegment} + + + + + ${ew.sqlSegment} + + + + + DELETE FROM Z_ABNORMAL_PLAN WHERE HANDLE=#{handle} + + + + DELETE FROM Z_ABNORMAL_PLAN + + + + + ${k} = #{cm[${k}]} + + + + + + + + DELETE FROM Z_ABNORMAL_PLAN + + + + + HANDLE=#{ew.entity.handle} + + AND SITE=#{ew.entity.site} + AND ABNORMAL_BILL_BO=#{ew.entity.abnormalBillBo} + AND STATUS=#{ew.entity.status} + AND WORK_CENTER=#{ew.entity.workCenter} + AND ABNORMAL_METHOD=#{ew.entity.abnormalMethod} + AND SHOP_ORDER=#{ew.entity.shopOrder} + AND RESRCE=#{ew.entity.resrce} + AND ITEM_BO=#{ew.entity.itemBo} + AND QTY=#{ew.entity.qty} + AND PROCESSOR=#{ew.entity.processor} + AND PROCESS_DATE_TIME=#{ew.entity.processDateTime} + AND CLOSED_USER=#{ew.entity.closedUser} + AND CLOSED_DATE_TIME=#{ew.entity.closedDateTime} + AND CREATED_USER=#{ew.entity.createdUser} + AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} + AND MODIFIED_USER=#{ew.entity.modifiedUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} + + + ${ew.sqlSegment} + + + + + ${ew.sqlSegment} + + + + + DELETE FROM Z_ABNORMAL_PLAN WHERE HANDLE IN ( + #{item} + ) + + + + diff --git a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java index 31e2ec81..a31535a0 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java @@ -167,5 +167,11 @@ public interface Constants { String TOOL_STATUS_Y = "Y"; String TOOL_STATUS_N = "N"; + /** + * 异常计划表的状态 + */ + String UNTREATED = "UNTREATED"; //未处理 + String PROCESSED = "PROCESSED"; //已处理 + } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java index 43d119fc..7a72e34a 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java @@ -106,10 +106,10 @@ public enum HandleEnum { RESOURCE_INSPECT_TASK_PARAM("ResourceInspectTaskParamBo","ResourceInspectTaskParamBo:{0},{1}"), /**异常单**/ - Z_ABNORMAL_BILL("AbnormalBillBo","AbnormalBillBo:{0},{1}"), + ABNORMAL_BILL("AbnormalBillBo","AbnormalBillBo:{0},{1}"), /**异常单详细表**/ - Z_ABNORMAL_BILL_DISPOSE("AbnormalBillDisposeBo","AbnormalBillDisposeBo:{0},{1}"), + ABNORMAL_BILL_DISPOSE("AbnormalBillDisposeBo","AbnormalBillDisposeBo:{0},{1}"), /**不良代码**/ NC_CODE("NCCodeBO","NCCodeBO:{0},{1}"), @@ -140,7 +140,9 @@ public enum HandleEnum { USER_RESOURCE("UserResourceBo","UserResourceBo:{0},{1},{2}"), - SFC_SCRAP("SfcScrapBo","SfcScrapBo:{0},{1}"); + SFC_SCRAP("SfcScrapBo","SfcScrapBo:{0},{1}"), + + ABNORMAL_PLAN("AbnormalPlanBo","AbnormalPlanBo:{0},{1}"); private String prefix; private String pattern; diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/InspectionTaskService.java b/common/src/main/java/com/foreverwin/mesnac/common/service/InspectionTaskService.java index ac7a6aa3..2dbcb9cf 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/InspectionTaskService.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/InspectionTaskService.java @@ -34,4 +34,6 @@ public interface InspectionTaskService extends IService { Map createTask(Map paramMap); InspectionTask isCreateTask(String site, String category, String sfc, String operation, String stepId); + + void createCompleteTask(Map paramMap); } \ No newline at end of file diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java index 38c71ce0..a5cb53f9 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java @@ -260,5 +260,48 @@ public class InspectionTaskServiceImpl extends ServiceImpl paramMap) { + String site = CommonMethods.getSite(); + String category = (String) paramMap.get("CATEGORY"); + String sfc = (String) paramMap.get("SFC"); + String shopOrder = (String) paramMap.get("SHOP_ORDER"); + String operation = (String) paramMap.get("OPERATION"); + String stepId = (String) paramMap.get("STEP_ID"); + String itemNumber = (String) paramMap.get("ITEM_NUMBER"); + + String handle = "InspectionTaskBO:" + site + "," + UUID.randomUUID().toString(); + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss"); + String taskNo = ""; + if (StringUtil.isBlank(itemNumber)) { + taskNo = "P_" + dateFormat1.format(date); + } else { + taskNo = "P_" + itemNumber + "_" + dateFormat1.format(date); + } + InspectionTask task = new InspectionTask(); + task.setHandle(handle); + task.setSite(site); + task.setCategory(category); + task.setTaskNo(taskNo); + task.setStatus(Constants.INSPECTION_TASK_STATUS_COMPLETE); + task.setResrce(Constants.RSESULT_OK); + task.setDescription("专检检验任务"); + task.setInspectionItemBo( null); + task.setShopOrder(shopOrder); + task.setWorkCenter((String) paramMap.get("WORK_CENTER")); + task.setSfc(sfc); + task.setOperation(operation); + task.setStepId(stepId); + task.setResrce((String) paramMap.get("RESRCE")); + task.setCreateUser(CommonMethods.getUser()); + task.setCreatedDateTime(LocalDateTime.now()); + task.setModifyUser(CommonMethods.getUser()); + task.setModifiedDateTime(LocalDateTime.now()); + task.setSfcDispatchBo((String) paramMap.get("SFC_DISPATCH_DETAIL_BO")); + task.setSfc(sfc); + save(task); + } + } \ No newline at end of file diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java index 363d8385..a5602c51 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java @@ -19,11 +19,14 @@ import com.foreverwin.mesnac.common.model.PrintLog; import com.foreverwin.mesnac.common.model.ProdReadyTask; import com.foreverwin.mesnac.common.model.ProdReadyTaskDetail; import com.foreverwin.mesnac.common.service.*; +import com.foreverwin.mesnac.common.util.ActiveMQUtil; import com.foreverwin.mesnac.common.util.DateUtil; import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.meapi.dto.BomComponentDto; +import com.foreverwin.mesnac.meapi.mapper.WorkCenterMapper; import com.foreverwin.mesnac.meapi.model.*; import com.foreverwin.mesnac.meapi.service.*; +import com.foreverwin.mesnac.meapi.util.StringUtils; import com.foreverwin.modular.core.exception.BaseException; import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.util.CommonMethods; @@ -75,21 +78,32 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl list = list(lambdaQueryWrapper); - if (list.size() >0) { + if (list.size() > 0) { ProdReadyTask prodReadyTask = list.get(0); if (prodReadyTask.getStatus().equals(STATUS_CANCEL)) { throw new BaseException("产前准备任务任务已取消"); @@ -285,17 +299,17 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl map=new HashMap<>(); - map.put("RESOURCE",sfcdispatch.getResrce()); - map.put("RESOURCE_TYPE",sfcdispatch.getResourceType()); - map.put("RESULT",jsonObject.get("RESULT")); - map.put("MESSAGE",jsonObject.get("MESSAGE")); + Map map = new HashMap<>(); + map.put("RESOURCE", sfcdispatch.getResrce()); + map.put("RESOURCE_TYPE", sfcdispatch.getResourceType()); + map.put("RESULT", jsonObject.get("RESULT")); + map.put("MESSAGE", jsonObject.get("MESSAGE")); returnMap.add(map); } return returnMap; @@ -429,21 +443,20 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl prodReadyTasks=prodReadyTaskMapper.getUnreadyTasks(site,now,endTime); - for(ProdReadyTask prodReadyTask : prodReadyTasks){ + List prodReadyTasks = prodReadyTaskMapper.getUnreadyTasks(site, now, endTime); + for (ProdReadyTask prodReadyTask : prodReadyTasks) { QueryWrapper messageQueryWrapper = new QueryWrapper<>(); - messageQueryWrapper.eq(Message.OBJECT_BO,prodReadyTask.getHandle()); + messageQueryWrapper.eq(Message.OBJECT_BO, prodReadyTask.getHandle()); List list = messageService.list(messageQueryWrapper); - if (!list.isEmpty()){ + if (!list.isEmpty()) { continue; } LambdaQueryWrapper lambdaQuery = new LambdaQueryWrapper<>(); lambdaQuery.eq(ProdReadyTaskDetail::getProdReadyTaskBo, prodReadyTask.getHandle()); List readyTaskDetails = prodReadyTaskDetailService.list(lambdaQuery); - for (ProdReadyTaskDetail prodReadyTaskDetail:readyTaskDetails){ - if (prodReadyTaskDetail.getInspectionItem().equals(P01)){ + for (ProdReadyTaskDetail prodReadyTaskDetail : readyTaskDetails) { + if (prodReadyTaskDetail.getInspectionItem().equals(P01)) { Message message = new Message(); String uuid = UUID.randomUUID().toString(); message.setHandle(uuid); @@ -453,56 +466,85 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl queryWrapper=new QueryWrapper<>(); - queryWrapper.eq(MessageTypeUserGroup.MESSAGE_TYPE_BO, new MessageTypeBOHandle(site,MESSAGE_TYPE_WLZB).getValue()); - queryWrapper.eq(MessageTypeUserGroup.USER_GROUP_BO,new UserGroupBOHandle(site,userGroup).getValue()); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(MessageTypeUserGroup.MESSAGE_TYPE_BO, new MessageTypeBOHandle(site, MESSAGE_TYPE_WLZB).getValue()); + queryWrapper.eq(MessageTypeUserGroup.USER_GROUP_BO, new UserGroupBOHandle(site, userGroup).getValue()); List messageTypeUserGroupList = messageTypeUserGroupService.list(queryWrapper); - if (messageTypeUserGroupList.isEmpty()){ + if (messageTypeUserGroupList.isEmpty()) { continue; } message.setSendUserGroup(userGroup); - message.setSendUser(""); - message.setContent(""); - message.setUpUserGroup(""); - message.setUpUser(""); - message.setUpMessageType(""); - message.setUpDateTime(LocalDateTime.now()); - message.setGrade(0.0D); - message.setResponseDateTime(LocalDateTime.now()); - message.setNode(""); - message.setStatus(""); - message.setCreatedUser(""); + message.setSendUser("JOB"); + String sendMessage = this.formatMessage(prodReadyTask, MESSAGE_TYPE_WLZB, site); + message.setContent(sendMessage); + message.setUpUserGroup(null); + message.setUpUser(null); + message.setUpMessageType(null); + message.setUpDateTime(null); + message.setGrade(null); + message.setResponseDateTime(null); + message.setNode(null); + message.setStatus(Constants.STATUS_Y); + message.setCreatedUser("JOB"); message.setCreatedDateTime(LocalDateTime.now()); - message.setModifiedUser(""); + message.setModifiedUser("JOB"); message.setModifiedDateTime(LocalDateTime.now()); - - -/* - List nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup()); + List nwaUsers = nwaUserService.checkUserGroup(site, userGroup); StringBuilder sendUsers = new StringBuilder(); for (int i = 0; i < nwaUsers.size(); i++) { - if(i == (nwaUsers.size() - 1)){ + if (i == (nwaUsers.size() - 1)) { sendUsers.append(nwaUsers.get(i)); - }else{ + } else { sendUsers.append(nwaUsers.get(i)).append("|"); } } - activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent()); -// } - messageService.saveOrUpdate(abnormalMessage);*/ - + messageService.save(message); + activeMQUtil.wechatSendMessage(sendUsers.toString(),sendMessage); } } } } + public String formatMessage(ProdReadyTask prodReadyTask, String messageType, String site) { + //找到消息内容 + String locale = LocaleContextHolder.getLocale().getLanguage(); + MessageType messageTypeEntity = new MessageType(); + messageTypeEntity.setSite(site); + messageTypeEntity.setMessageType(messageType); + QueryWrapper messageTypeQueryWrapper = new QueryWrapper(); + messageTypeQueryWrapper.setEntity(messageTypeEntity); + MessageType sendMessageType = messageTypeService.getOne(messageTypeQueryWrapper); + if (sendMessageType == null) { + throw new BaseException("异常提报时找不到要发送的消息类型"); + } + //格式化消息 + String body = sendMessageType.getBody(); + //替换消息类型中的参数 + Map messageMap = new HashMap<>(); + //根据车间找到对应车间的描述 + WorkCenter workCenter = workCenterMapper.findWorkCenterDescriptionByWorkCenter(site, prodReadyTask.getWorkCenter(), locale); + //根据资源找到对应的产线的描述 + Resrce byResrce = resrceService.findByResrce(prodReadyTask.getResrce()); + Item selectCurrent = itemService.selectCurrent(site, prodReadyTask.getItem()); + //项目号 + String item = selectCurrent.getItem() + "/" + selectCurrent.getDescription(); + messageMap.put("WORKCENTER", workCenter.getDescription()); + messageMap.put("RESOURCE", byResrce + "/" + byResrce.getDescription()); + messageMap.put("ITEM", item); + messageMap.put("SHOPORDER", prodReadyTask.getShopOrder()); + messageMap.put("SFC", prodReadyTask.getSfc()); + + //格式化之后的消息 + return StringUtils.format(body, messageMap); + } + public JSONObject sendToDnc(String item, String resource, String resourceType) { String site = CommonMethods.getSite(); - String queue="resource.check.process"; - JSONObject messageObject=new JSONObject(); + String queue = "resource.check.process"; + JSONObject messageObject = new JSONObject(); String tranid = UUID.randomUUID().toString(); messageObject.put("TRANID", tranid); String dateTime = DateUtil.formatDate(new Date()); diff --git a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/UserResourceHandler.java b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/UserResourceHandler.java index 7e52648c..65043a50 100644 --- a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/UserResourceHandler.java +++ b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/UserResourceHandler.java @@ -15,7 +15,6 @@ import com.foreverwin.mesnac.meapi.mapper.NwaUserMapper; import com.foreverwin.mesnac.meapi.mapper.ResrceMapper; import com.foreverwin.mesnac.meapi.model.NwaUser; import com.foreverwin.mesnac.meapi.model.Resrce; -import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.util.CommonMethods; import com.foreverwin.modular.core.util.I18nUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -58,10 +57,10 @@ public class UserResourceHandler extends BaseHandler { buffer.append(e.getMessage() + "\n"); } - if (buffer.length() > 0) { - buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n"); - throw BusinessException.build(buffer.toString()); - } +// if (buffer.length() > 0) { +// buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n"); +// throw BusinessException.build(buffer.toString()); +// } buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n"); return buffer.toString(); @@ -126,15 +125,13 @@ public class UserResourceHandler extends BaseHandler { //站点 jsonObject.put("site", site); //不管用户选啥模式,都是更新和插入 - resultMessage = this.updateAndInsert(userResource,index); - + resultMessage = updateAndInsert(userResource,index); if (resultMessage != null) { params[2] = resultMessage; failedNumber[0]++; buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n"); return 0; } - userResourceService.saveOrUpdate(userResource); return 1; } return 0; @@ -144,30 +141,29 @@ public class UserResourceHandler extends BaseHandler { public String[] getHeader() { return null; } - - String updateAndInsert(UserResource userResource,Long index){ - //判断资源是否存在 - Resrce resrce = resrceMapper.selectById(userResource.getResourceBo()); - - if(resrce == null){ - return "第"+index+"行的资源不存在"; - } - //设置资源描述 - userResource.setResrceDescription(resrce.getDescription()); - //设置员工描述 - NwaUser nwaUser = nwaUserMapper.selectById(HandleEnum.USER.getHandle(userResource.getSite(), userResource.getUserId())); - if(nwaUser != null){ - userResource.setUserDescription(nwaUser.getFullName()); - }else if("true".equals(userResource.getTemporaryUser())){ - //不做任何操作 - }else{ - return "第"+index+"行的用户不存在,必须为临时员工"; - } - return null; - } }; + } + String updateAndInsert(UserResource userResource,Long index){ + //判断资源是否存在 + Resrce resrce = resrceMapper.selectById(userResource.getResourceBo()); + if(resrce == null){ + return "第"+index+"行的资源不存在"; + } + //设置资源描述 + userResource.setResrceDescription(resrce.getDescription()); + //设置员工描述 + NwaUser nwaUser = nwaUserMapper.selectById(HandleEnum.USER.getHandle(userResource.getSite(), userResource.getUserId())); + if(nwaUser != null){ + userResource.setUserDescription(nwaUser.getFullName()); + }else if("true".equals(userResource.getTemporaryUser())){ + //不做任何操作 + }else{ + return "第"+index+"行的用户不存在,必须为临时员工"; + } + userResourceService.saveOrUpdate(userResource); + return null; } } diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java b/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java index 29c591cd..1a41a4a6 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java @@ -4,7 +4,7 @@ import com.foreverwin.mesnac.meapi.dto.SfcDto; import com.foreverwin.mesnac.meapi.dto.WorkCenterDto; import com.foreverwin.mesnac.meapi.model.Sfc; -import java.math.BigDecimal; +import java.util.List; import java.util.Map; public interface PodTemplateService { @@ -18,7 +18,7 @@ public interface PodTemplateService { void sfcComplete(Map map); - void sendErp(String sfc, String stepId, BigDecimal qty, BigDecimal scrapQty); + void sendErp(List> mapList); SfcDto getInfoBySfc(Sfc sfc); diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java index c2f2dfa3..8a6db676 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java @@ -46,7 +46,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.math.RoundingMode; import java.rmi.RemoteException; +import java.time.Duration; import java.time.LocalDateTime; import java.util.*; @@ -217,6 +219,16 @@ public class PodTemplateServiceImpl implements PodTemplateService { throw new BaseException("互检任务不合格,不能开始请检查"); } } + //是否完成专检 + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq(InspectionTask.CATEGORY,Constants.INSPECTION_TYPE_P); + queryWrapper.eq(InspectionTask.SFC,sfc); + queryWrapper.ne(InspectionTask.STATUS,Constants.INSPECTION_TASK_STATUS_COMPLETE); + queryWrapper.ne(InspectionTask.RESULT,Constants.RSESULT_OK); + List list = inspectionTaskService.list(queryWrapper); + if (!list.isEmpty()) { + throw new BaseException("请完成专检检验任务"); + } try { sfcCrossService.startAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty); } catch (Exception e) { @@ -232,8 +244,8 @@ public class PodTemplateServiceImpl implements PodTemplateService { public void sfcComplete(Map map) { List sfcDtoList = (List) map.get("sfcDtoList"); ObjectMapper mapper = new ObjectMapper(); - sfcDtoList = mapper.convertValue(sfcDtoList, new TypeReference>() { - }); + sfcDtoList = mapper.convertValue(sfcDtoList, new TypeReference>() {}); + List> postMapList=new ArrayList<>(); String resrce = (String) map.get("resrce"); if (sfcDtoList == null || sfcDtoList.size() < 1) { throw new BaseException("作业列表不能为空"); @@ -242,6 +254,7 @@ public class PodTemplateServiceImpl implements PodTemplateService { throw new BaseException("资源不能为空"); } for (SfcDto sfcDto:sfcDtoList){ + Map postMap=new HashMap<>(); String site = CommonMethods.getSite(); String operation = sfcDto.getOperation(); Operation currentRevisionRef = operationService.getCurrentRevisionRef(site, operation); @@ -291,6 +304,9 @@ public class PodTemplateServiceImpl implements PodTemplateService { if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { paramMap.put("CATEGORY",Constants.INSPECTION_TYPE_P); inspectionTaskService.createTask(paramMap); + }else { + paramMap.put("CATEGORY",Constants.INSPECTION_TYPE_P); + inspectionTaskService.createCompleteTask(paramMap); } //首件创建 inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc,operation, stepId, Constants.INSPECTION_TYPE_S); @@ -298,15 +314,26 @@ public class PodTemplateServiceImpl implements PodTemplateService { paramMap.put("CATEGORY",Constants.INSPECTION_TYPE_S); inspectionTaskService.createTask(paramMap); } + //计算工时 + LocalDateTime startTime = sfcService.getSfcStartTime(HandleEnum.SFC.getHandle(site, sfc)); + long workHourSeconds = Duration.between(startTime, LocalDateTime.now()).getSeconds(); + BigDecimal workHour = new BigDecimal(workHourSeconds).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP); + postMap.put("sfc",sfc); + postMap.put("stepId",stepId); + postMap.put("qty",qty); + postMap.put("scrapQty",BigDecimal.ZERO); + postMap.put("workHour",workHour); + postMapList.add(postMap); sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty); //更改派工单状态 sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode()); - //报工 - //sendErp(sfc, stepId, qty,BigDecimal.ZERO); + } catch (Exception e) { ExceptionUtil.throwException(e); } } + //报工 + //sendErp(postMapList); } public void materialConsumption(String site, String operation, String sfcBo, String stepId, String resource) { @@ -399,40 +426,48 @@ public class PodTemplateServiceImpl implements PodTemplateService { } @Override - public void sendErp(String sfc, String stepId, BigDecimal qty, BigDecimal scrapQty) { - Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(CommonMethods.getSite(),sfc)); - String shopOrderBo = sfcServiceById.getShopOrderBo(); - String shopOrder = StringUtil.trimHandle(shopOrderBo); + public void sendErp(List> postMapList) { //请求参数 ZprodordconfStruIn[] ins = new ZprodordconfStruIn[1]; + for (int i=0;i map = postMapList.get(i); + String sfc = (String)map.get("sfc"); + Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(CommonMethods.getSite(),sfc)); + String shopOrderBo = sfcServiceById.getShopOrderBo(); + String shopOrder = StringUtil.trimHandle(shopOrderBo); + String stepId = (String)map.get("stepId"); + BigDecimal qty = (BigDecimal) map.get("qty"); + BigDecimal scrapQty = (BigDecimal)map.get("scrapQty"); + BigDecimal workHour = (BigDecimal)map.get("workHour"); + ZprodordconfStruIn struIn = new ZprodordconfStruIn(); + //生产订单 + struIn.setAufnr(shopOrder); + //步骤标示 + struIn.setVornr(stepId); + struIn.setAueru("1"); + //良品数量 + struIn.setLmnga(qty); + //报废数量 + struIn.setXmnga(scrapQty); + //机器工时 + struIn.setIsm01(workHour); + //人工工时 + struIn.setIsm02(workHour); + struIn.setIsm03(BigDecimal.ZERO); + struIn.setIsm04(BigDecimal.ZERO); + struIn.setIsm05(BigDecimal.ZERO); + struIn.setIsm06(BigDecimal.ZERO); + ins[i] = struIn; + } - ZprodordconfStruIn struIn = new ZprodordconfStruIn(); - //生产订单 - struIn.setAufnr(shopOrder); - //步骤标示 - struIn.setVornr(stepId); - struIn.setAueru("1"); - //良品数量 - struIn.setLmnga(qty); - //报废数量 - struIn.setXmnga(scrapQty); - //机器工时 - struIn.setIsm01(BigDecimal.ZERO); - //人工工时 - struIn.setIsm02(BigDecimal.ZERO); - struIn.setIsm03(BigDecimal.ZERO); - struIn.setIsm04(BigDecimal.ZERO); - struIn.setIsm05(BigDecimal.ZERO); - struIn.setIsm06(BigDecimal.ZERO); - ins[0] = struIn; TableOfZprodordconfStruInHolder inHolder = new TableOfZprodordconfStruInHolder(ins); //返回对象 ZprodordconfStruOut[] outs = new ZprodordconfStruOut[1]; ZprodordconfStruOut struOut = new ZprodordconfStruOut(); - struOut.setAufnr(shopOrder); - struOut.setVornr(stepId); + struOut.setAufnr(""); + struOut.setVornr(""); struOut.setAueru("1"); struOut.setLmnga(new BigDecimal(1)); struOut.setRet(""); @@ -455,10 +490,10 @@ public class PodTemplateServiceImpl implements PodTemplateService { log.setHandle(UUID.randomUUID().toString()); log.setSite(CommonMethods.getSite()); log.setIntegrationType(IntegrationTypeConstant.ROUTER); - log.setCategory("SEND"); + log.setCategory("REQUEST"); log.setIntegrationWay("ERP"); log.setIntegrationMethod("erpWebService.zmesProdordconf"); - log.setParam(struIn.toString()); + log.setParam(ins.toString()); log.setStatus(outHolder.value[1].getRet()); log.setResultMessage(outHolder.value[1].getMsg()); log.setTransactionId("");