소스 검색

1、盘库管理

QuietShadow 2 년 전
부모
커밋
9fe2a85ee0

+ 1 - 1
src/main/java/com/steerinfo/ems/Utils/DateUtils.java

@@ -179,7 +179,7 @@ public class DateUtils {
     public static Date getCurrentTimetoDate(String timeformat) {
         try {
             Date date = new java.sql.Date(new Date().getTime());
-            String datestr = new SimpleDateFormat("yyyy-mm-dd").format(date);
+            String datestr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
             Date time = new SimpleDateFormat(timeformat).parse(datestr);
             return time;
         }

+ 73 - 30
src/main/java/com/steerinfo/ems/ifmesemsswapfile/controller/IfMesEmsSwapfileController.java

@@ -25,91 +25,91 @@ public class IfMesEmsSwapfileController extends BaseRESTfulController {
     @Autowired
     IIfMesEmsSwapfileService ifMesEmsSwapfileService;
 
-    @ApiOperation(value="获取列表", notes="分页查询")
+    @ApiOperation(value = "获取列表", notes = "分页查询")
     @ApiImplicitParams({
-        @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
-        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
+            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
+            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
     })
     //@RequiresPermissions("trmunit:view")
     @GetMapping(value = "/")
-    public RESTfulResult list(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
+    public RESTfulResult list(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
         PageList<IfMesEmsSwapfile> list = ifMesEmsSwapfileService.queryForPage(parmas, pageNum, pageSize);
         return success(list);
     }
-    
-    @ApiOperation(value="获取列表", notes="分页模糊查询")
+
+    @ApiOperation(value = "获取列表", notes = "分页模糊查询")
     @ApiImplicitParams({
-        @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
-        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
+            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
+            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
     })
     //@RequiresPermissions("tpmcaseact:view")
     @GetMapping(value = "/like/")
-    public RESTfulResult listLike(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
+    public RESTfulResult listLike(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
         PageList<IfMesEmsSwapfile> list = ifMesEmsSwapfileService.queryLikeForPage(parmas, pageNum, pageSize);
         return success(list);
     }
 
 
-    @ApiOperation(value="立即从MES同步数据", notes="从MES同步投入产出数据")
+    @ApiOperation(value = "立即从MES同步数据", notes = "从MES同步投入产出数据")
     @PostMapping(value = "/synchronousMesAnEmsData")
-    public RESTfulResult synchronousMesAnEmsData(@ModelAttribute IfMesEmsSwapfile model){
+    public RESTfulResult synchronousMesAnEmsData(@ModelAttribute IfMesEmsSwapfile model) {
         String s = ifMesEmsSwapfileService.synchronousMesAnEmsData();
         return success(s);
     }
 
     @GetMapping("/getLgDateProd")
-    public RESTfulResult getLgDateProd (){
+    public RESTfulResult getLgDateProd() {
         ifMesEmsSwapfileService.getLgDateProd();
         return success();
     }
 
-    @ApiOperation(value="获取列表", notes="分页模糊查询")
+    @ApiOperation(value = "获取列表", notes = "分页模糊查询")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
             @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
     })
     //@RequiresPermissions("tpmcaseact:view")
     @GetMapping(value = "/queryList/")
-    public RESTfulResult queryList(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
-        if(parmas.containsKey("workprocid") && parmas.get("workprocid") != null && !"".equals(parmas.get("workprocid").toString())){
+    public RESTfulResult queryList(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
+        if (parmas.containsKey("workprocid") && parmas.get("workprocid") != null && !"".equals(parmas.get("workprocid").toString())) {
             PageList<Map<String, Object>> list = ifMesEmsSwapfileService.getQueryList(parmas, pageNum, pageSize);
             return success(list);
         }
         return failed(null, "菜单工序id为空,请联系管理员");
     }
 
-    @ApiOperation(value="获取列表", notes="分页模糊查询")
+    @ApiOperation(value = "获取列表", notes = "分页模糊查询")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
             @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
     })
     @GetMapping(value = "/queryProductAndMaterial/")
-    public RESTfulResult queryProductAndMaterial(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
-        if(parmas.containsKey("workprocid") && parmas.get("workprocid") != null && !"".equals(parmas.get("workprocid").toString())){
-            if(parmas.containsKey("type") && parmas.get("type") != null && !"".equals(parmas.get("type").toString())) {
+    public RESTfulResult queryProductAndMaterial(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
+        if (parmas.containsKey("workprocid") && parmas.get("workprocid") != null && !"".equals(parmas.get("workprocid").toString())) {
+            if (parmas.containsKey("type") && parmas.get("type") != null && !"".equals(parmas.get("type").toString())) {
                 Object type = parmas.get("type");
                 if ("1".equals(type)) {
-                    parmas.put("table_name","T_RM_WORKPROC_MATERIAL");
-                    parmas.put("table_name2","T_RM_WORKPROC_MATERIAL_VALUE");
-                    parmas.put("listing","MATERIALID");
+                    parmas.put("table_name", "T_RM_WORKPROC_MATERIAL");
+                    parmas.put("table_name2", "T_RM_WORKPROC_MATERIAL_VALUE");
+                    parmas.put("listing", "MATERIALID");
                 } else if ("2".equals(type)) {
-                    parmas.put("table_name","T_RM_WORKPROC_PRODUCT");
-                    parmas.put("table_name2","T_RM_WORKPROC_PRODUCT_VALUE");
-                    parmas.put("listing","PRODUCTID");
+                    parmas.put("table_name", "T_RM_WORKPROC_PRODUCT");
+                    parmas.put("table_name2", "T_RM_WORKPROC_PRODUCT_VALUE");
+                    parmas.put("listing", "PRODUCTID");
                 } else {
                     return failed(null, "数据类型有误");
                 }
                 PageList<Map<String, Object>> list = ifMesEmsSwapfileService.queryProductAndMaterial(parmas, pageNum, pageSize);
                 return success(list);
             }
-            return failed(null,"请选择数据类型");
+            return failed(null, "请选择数据类型");
         }
         return failed(null, "菜单工序id为空,请联系管理员");
     }
 
-    @ApiOperation(value="批量更新详细信息", notes="根据传过来的parmas数组信息来更新详细信息")
+    @ApiOperation(value = "批量更新详细信息", notes = "根据传过来的parmas数组信息来更新详细信息")
     @ApiImplicitParam(name = "parmas", value = "详细实体usageData", required = true, dataType = "usageData")
-    @PutMapping(value = "/updateProductAndMaterial", produces  = "application/json;charset=UTF-8")
+    @PutMapping(value = "/updateProductAndMaterial", produces = "application/json;charset=UTF-8")
     public RESTfulResult updateProductAndMaterial(@RequestBody HashMap[] parmas) {
 
         for (int i = 0; i < parmas.length; i++) {
@@ -148,18 +148,61 @@ public class IfMesEmsSwapfileController extends BaseRESTfulController {
         }
         return success();
     }
+
     @Autowired
     ITRmWorkprocProductValueService tRmWorkprocProductValueService;
 
     @Autowired
     ITRmWorkprocMaterialValueService tRmWorkprocMaterialValueService;
 
-    @ApiOperation(value="从T_RM_PRODUCT,T_RM_MATERIAL生成模板数据", notes="从生成投入产出数据模板")
+    @ApiOperation(value = "从T_RM_PRODUCT,T_RM_MATERIAL生成模板数据", notes = "从生成投入产出数据模板")
     @GetMapping(value = "/generateProductAndMaterial")
-    public RESTfulResult generateProductAndMaterial(@ModelAttribute IfMesEmsSwapfile model){
+    public RESTfulResult generateProductAndMaterial(@ModelAttribute IfMesEmsSwapfile model) {
         String s = ifMesEmsSwapfileService.generateProductAndMaterial();
         tRmWorkprocProductValueService.synchronousData();
         tRmWorkprocMaterialValueService.synchronousData();
         return success(s);
     }
+
+    @ApiOperation(value = "查询盘库数据,获取列表", notes = "分页模糊查询")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
+            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
+    })
+    @GetMapping(value = "/queryWorkprocInventory/")
+    public RESTfulResult queryWorkprocInventory(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
+        PageList<Map<String, Object>> list = ifMesEmsSwapfileService.queryWorkprocInventory(parmas, pageNum, pageSize);
+        return success(list);
+    }
+
+    @ApiOperation(value = "批量更新盘库数据详细信息", notes = "根据传过来的parmas数组信息来更新详细信息")
+    @ApiImplicitParam(name = "parmas", value = "详细实体usageData", required = true, dataType = "usageData")
+    @PutMapping(value = "/updateWorkprocInventory", produces = "application/json;charset=UTF-8")
+    public RESTfulResult updateWorkprocInventory(@RequestBody HashMap[] parmas) {
+        for (int i = 0; i < parmas.length; i++) {
+            HashMap parma = parmas[i];
+            if (!parma.containsKey("itemid") || parma.get("itemid") == null || "".equals(parma.get("itemid").toString())) {
+                return failed(null, "缺少参数itemid");
+            }
+            if (!parma.containsKey("tableName") || parma.get("tableName") == null || "".equals(parma.get("tableName").toString())) {
+                return failed(null, "缺少参数tableName");
+            }
+            if (!parma.containsKey("clock") || parma.get("clock") == null || "".equals(parma.get("clock").toString())) {
+                return failed(null, "缺少参数clock");
+            }
+            if (!parma.containsKey("timegranid") || parma.get("timegranid") == null || "".equals(parma.get("timegranid").toString())) {
+                return failed(null, "缺少参数timegranid");
+            }
+            if (!parma.containsKey("JTZ") || parma.get("JTZ") == null || "".equals(parma.get("JTZ").toString())) {
+                return failed(null, "缺少参数JTZ");
+            }
+            if (!parma.containsKey("bz")) {
+                return failed(null, "缺少参数bz");
+            }
+            parma.put("upman", JwtUtil.getUseridByToken());
+            parma.put("uptime", DateUtils.getCurrentTimetoDate("yyyy-MM-dd HH:mm:ss"));
+            ifMesEmsSwapfileService.updateWorkprocInventory(parma);
+        }
+        return success();
+    }
 }

+ 4 - 0
src/main/java/com/steerinfo/ems/ifmesemsswapfile/mapper/IfMesEmsSwapfileMapper.java

@@ -24,4 +24,8 @@ public interface IfMesEmsSwapfileMapper extends IBaseMapper<IfMesEmsSwapfile, St
     List<Map<String, Object>> queryProductAndMaterial(HashMap<String, Object> parmas);
 
     int updateProductAndMaterial(HashMap<String, Object> parmas);
+
+    List<Map<String, Object>> queryWorkprocInventory(HashMap<String, Object> parmas);
+
+    int updateWorkprocInventory(HashMap<String, Object> parmas);
 }

+ 60 - 0
src/main/java/com/steerinfo/ems/ifmesemsswapfile/mapper/IfMesEmsSwapfileMapper.xml

@@ -370,4 +370,64 @@
         AND TIMEGRANID = #{timegranid}
         AND ACTUALVALUE = #{actualvalue}
     </update>
+
+    <select id="queryWorkprocInventory" parameterType="java.util.HashMap" resultType = "Map">
+        SELECT 	CLOCK,
+        TIMEGRANID,
+        ITEMID,
+        WORKPROCID,
+        CODE,
+        ACTUALVALUE,
+        CORRECTVALUE,
+        APPORTVALUE,
+        BZ,
+        USERID,
+        UPDATETIME,
+        UPMAN,
+        UPTIME,
+        PKL,
+        JTZ,
+        TABLENAME,
+        UNITID
+        FROM VM_WORKPROC_INVENTORY
+        WHERE 1 = 1
+        <if test="startDate != null and startDate != ''">
+            AND CLOCK >= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != ''">
+            AND CLOCK &lt;= #{endDate}
+        </if>
+        <if test="timegranid != null and clock2 != ''">
+            AND TIMEGRANID = #{timegranid}
+        </if>
+        AND ITEMTYPE = 'R'
+        AND USEFLAG = '1'
+        AND ISFINANCEDATA = '1'
+        <if test="workprocid != null and workprocid != ''">
+            AND WORKPROCID IN (${workprocid})
+        </if>
+        <if test="materialid != null and materialid != ''">
+            AND code IN (${materialid})
+        </if>
+        <if test="itemid != null and itemid != ''">
+            AND ITEMID LIKE '%${itemid}%'
+        </if>
+        <if test="itemtype !=null and itemtype!='' ">
+            AND ITEMTYPE = #{itemtype}
+        </if>
+        ORDER BY CLOCK,SEQNO
+    </select>
+
+    <update id="updateWorkprocInventory" parameterType="java.util.HashMap">
+        UPDATE ${tableName}
+        SET JTZ = #{JTZ},
+        <if test="bz != null and bz != ''">
+            BZ = #{bz},
+        </if>
+        UPMAN = #{upman},
+        UPTIME = #{uptime}
+        WHERE ITEMID = #{itemid}
+        AND CLOCK = #{clock}
+        AND TIMEGRANID = #{timegranid}
+    </update>
 </mapper>

+ 17 - 0
src/main/java/com/steerinfo/ems/ifmesemsswapfile/service/IIfMesEmsSwapfileService.java

@@ -85,4 +85,21 @@ public interface IIfMesEmsSwapfileService extends IBaseService<IfMesEmsSwapfile,
 	String generateProductAndMaterial();
 
     void getLgDateProd2() throws ParseException;
+
+	/**
+	 * 查询盘库数据
+	 *
+	 * @param parmas
+	 * @param pageNum
+	 * @param pageSize
+	 * @return
+	 */
+	PageList<Map<String, Object>> queryWorkprocInventory(HashMap<String, Object> parmas, Integer pageNum, Integer pageSize);
+
+	/**
+	 * 修改盘库数据
+	 * @param parmas 参数
+	 * @return
+	 */
+	int updateWorkprocInventory(HashMap<String, Object> parmas);
 }

+ 23 - 0
src/main/java/com/steerinfo/ems/ifmesemsswapfile/service/impl/IfMesEmsSwapfileServiceImpl.java

@@ -318,4 +318,27 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
 		}
 		return "本次共生成" + addSize + "条";
 	}
+
+	@Override
+	public PageList<Map<String, Object>> queryWorkprocInventory(HashMap<String, Object> parmas, Integer pageNum, Integer pageSize) {
+		PageHelper.startPage(pageNum, pageSize);
+		if (parmas.get("workprocid") != null && !parmas.get("workprocid").toString().isEmpty()) {
+			String workProcids = parmas.get("workprocid").toString();
+			workProcids = "'" + workProcids.replaceAll(",", "','").replaceAll(",", "','") + "'";
+			parmas.put("workprocid", workProcids);
+		}
+		if (parmas.get("materialid") != null && !parmas.get("materialid").toString().isEmpty()) {
+			String materialid = parmas.get("materialid").toString();
+			materialid = "'" + materialid.replaceAll(",", "','").replaceAll(",", "','") + "'";
+			parmas.put("materialid", materialid);
+		}
+		List<Map<String, Object>> rows = ifmesemsswapfilemapper.queryWorkprocInventory(parmas);
+		PageList<Map<String, Object>> pageInfo = new PageList<Map<String, Object>>(rows);
+		return pageInfo;
+	}
+
+	@Override
+	public int updateWorkprocInventory(HashMap<String, Object> parmas) {
+		return ifmesemsswapfilemapper.updateWorkprocInventory(parmas);
+	}
 }

+ 11 - 10
src/main/java/com/steerinfo/task/SpringCronTask.java

@@ -211,10 +211,10 @@ public class SpringCronTask implements SchedulingConfigurer{
 		return new Runnable() {
 			@Override
 			public void run() {
-//				if(!props.getProperty("os.name").equalsIgnoreCase("linux")){
-//					System.out.println("操作系统:" + props.getProperty("os.name") + ", 非linux环境不运行定时任务");
-//					return;
-//				}
+				if(!props.getProperty("os.name").equalsIgnoreCase("linux")){
+					System.out.println("操作系统:" + props.getProperty("os.name") + ", 非linux环境不运行定时任务");
+					return;
+				}
 //				if (taskId.equalsIgnoreCase("101")) { // 定时任务1的业务处理-MES数据同步
 //					logger.info("定时任务触发时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
 //					long start = System.currentTimeMillis();
@@ -243,12 +243,13 @@ public class SpringCronTask implements SchedulingConfigurer{
 				 else  if (taskId.equalsIgnoreCase("105")) {
 					// 先计算产品,因为原材料计算单耗需要产品实绩数据参与计算
 					long start = System.currentTimeMillis();
-					ifMesEmsSwapfileService.getLgDateProd();
-					try {
-						ifMesEmsSwapfileService.getLgDateProd2();
-					} catch (ParseException e) {
-						e.printStackTrace();
-					}
+					//2022-07-11 张琰 注释,现有逻辑是从报表获取数据。
+					//ifMesEmsSwapfileService.getLgDateProd();
+					//try {
+					//	ifMesEmsSwapfileService.getLgDateProd2();
+					//} catch (ParseException e) {
+					//	e.printStackTrace();
+					//}
 					tRmWorkprocProductValueService.setDate(new Date()); // 产品实绩产量、产品计划数据维护
 					tRmWorkprocMaterialValueService.setDate(new Date()); // 原材料数据维护
 					logger.info("定时任务"+taskId+"执行时长:" + (System.currentTimeMillis() - start)/1000 + "秒");