pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrAssemblyPlan.java
@@ -43,6 +43,9 @@ @JSONField(serializeUsing= ObjectWriterImplToString.class) public Long orderId; @TableField(exist = false) public String orderName; /** * 批次实体编号 */ pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
@@ -29,6 +29,8 @@ select="com.dy.pmsGlobal.daoPr.PrBatchNumberMapper.selectBatchNoById" fetchType="eager"/> <association property="processName" column="process_id" javaType="java.lang.Long" select="com.dy.pmsGlobal.daoPr.PrProductionProcessMapper.selectProcessNameById" fetchType="eager"/> <association property="orderName" column="order_id" javaType="java.lang.Long" select="com.dy.pmsGlobal.daoPr.PrOrderMapper.selectOrderNameById" fetchType="eager" /> <collection property="process" ofType="com.dy.pmsGlobal.pojoPr.PrProductionProcess" select="com.dy.pmsGlobal.daoPr.PrProductionProcessMapper.selectByPrimaryKey" fetchType="eager" column="process_id"/> pms-parent/pms-global/src/main/resources/mapper/PrOrderMapper.xml
@@ -33,7 +33,9 @@ from pr_order where id = #{id,jdbcType=BIGINT} </select> <select id="selectOrderNameById" parameterType="java.lang.Long" resultType="String"> select name from pr_order where id=#{orderId,jdbcType=BIGINT} </select> <select id="exists" resultType="java.lang.Boolean"> select count(1) from pr_order where name = #{name} <if test="id != null"> pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderCtrl.java
@@ -21,17 +21,19 @@ */ @Slf4j @RestController @RequestMapping(path="order") @RequestMapping(path = "order") public class OrderCtrl { private OrderSv sv; @Autowired public void setAssemblySv(OrderSv orderSv) { this.sv = orderSv; } @PostMapping(path="save") @PostMapping(path = "save") @SsoPowerAop(power = "10200001") @Log("保存订单信息") public BaseResponse<Boolean> save(@RequestBody @Valid PrOrder order){ public BaseResponse<Boolean> save(@RequestBody @Valid PrOrder order) { int count = sv.save(order); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); @@ -42,13 +44,14 @@ /** * 更新 * * @param order * @return */ @PostMapping(path="update") @PostMapping(path = "update") @SsoPowerAop(power = "10200001") @Log("修改订单信息") public BaseResponse<Boolean> update(@RequestBody @Valid PrOrder order){ public BaseResponse<Boolean> update(@RequestBody @Valid PrOrder order) { int count = sv.update(order); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); @@ -59,13 +62,14 @@ /** * 删除订单信息 * * @param id * @return */ @GetMapping(path="delete") @GetMapping(path = "delete") @SsoPowerAop(power = "10300001") @Log("删除订单信息") public BaseResponse<Boolean> delete(String id){ public BaseResponse<Boolean> delete(String id) { int count = sv.delete(Long.parseLong(id)); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); @@ -76,46 +80,49 @@ /** * 根据ID查询 * * @return */ @GetMapping(path="one") @GetMapping(path = "one") @SsoPowerAop(power = "10200000") @Log("根据ID查询订单信息") public BaseResponse<PrOrder> one(String id){ PrOrder plan=sv.selectById(id); public BaseResponse<PrOrder> one(String id) { PrOrder plan = sv.selectById(id); return BaseResponseUtils.buildSuccess(plan); } /** * 分页查询 * * @param vo * @return */ @PostMapping(path="some") @PostMapping(path = "some") @SsoPowerAop(power = "10200000") @Log("分页查询订单信息") public BaseResponse<QueryResultVo<List<PrOrder>>> some(@RequestBody QueryVo vo){ QueryResultVo<List<PrOrder>> list = sv.selectSome(vo) ; public BaseResponse<QueryResultVo<List<PrOrder>>> some(@RequestBody QueryVo vo) { QueryResultVo<List<PrOrder>> list = sv.selectSome(vo); return BaseResponseUtils.buildSuccess(list); } /** * 查询所有订单 * * @return */ @GetMapping(path="all") @GetMapping(path = "all") @SsoPowerAop(power = "10300000") @Log("查询所有产品") public BaseResponse<List<PrOrder>> all(){ public BaseResponse<List<PrOrder>> all() { QueryVo vo = new QueryVo(); return BaseResponseUtils.buildSuccess(sv.selectAll(vo)); } @PostMapping(path="updateStatus") @PostMapping(path = "updateStatus") @SsoPowerAop(power = "10200001") @Log("更新任务计划状态") public BaseResponse<Boolean> updateStatus(@RequestBody PrAssemblyPlan plan){ int count = 0;//sv.updateStatus(plan); @Log("更新订单状态") public BaseResponse<Boolean> updateStatus(@RequestBody PrOrder order) { int count = 0; //sv.updateStatus(plan); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderSv.java
@@ -6,6 +6,7 @@ import com.dy.pmsGlobal.pojoBa.BaUser; import com.dy.pmsGlobal.pojoPr.*; import com.dy.pmsGlobal.util.UserUtil; import com.dy.pmsProduct.taskPlan.PlanStatusEnum; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -14,6 +15,8 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; @@ -151,4 +154,42 @@ } return orderList; } /** * 只更新状态,不更新其他字段 * @param plan * 更新状态 如果有在执行中的任务,不让暂停 * @return */ /* @Transactional public int updateStatus(PrOrder plan) { if(plan.status == PlanStatusEnum.NORMAL.getCode()){ PrAssemblyPlan assemblyPlan = assemblyDao.selectByPrimaryKey(plan.id); assemblyPlan.status = plan.status; extractedCheck(assemblyPlan); } PrAssemblyPlan param = new PrAssemblyPlan(); param.id =plan.id; param.status = plan.status; return assemblyDao.updateByPrimaryKeySelective(param); } private void extractedCheck(PrAssemblyPlan plan) { PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId); if(process == null || !process.proId.equals(plan.proId)){ throw new RuntimeException("产品与生产流程不匹配"); } //开始日期要小于结束日期 if(plan.startDate.compareTo(plan.endDate) > 0){ throw new RuntimeException("开始日期不能大于结束日期"); } //Fancy add 2024/07/09 如果状态为执行 ,则结束日期必须大于等于当前日期 if(plan.status == PlanStatusEnum.NORMAL.getCode()){ String endDateStr = plan.getEndDate(); LocalDate endDate = LocalDate.parse(endDateStr, DateTimeFormatter.ISO_LOCAL_DATE); LocalDate nextDay = endDate.plusDays(1); LocalDate today = LocalDate.now(); // 获取当前日期 if (nextDay.isBefore(today)) { throw new RuntimeException("执行状态结束日期必须大于等于当前日期,请修改结束日期"); } } }*/ }