add资源负荷率报表(周维度)

master
yinq 2 years ago
parent bda7107a9d
commit cc495948d8

@ -483,8 +483,6 @@ public class AbnormalBillController {
}
}
/**
*
*/

@ -6,6 +6,8 @@ package com.foreverwin.mesnac.anomaly.controller;
* @Since 2021-08-23
*/
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.foreverwin.mesnac.anomaly.service.ReportService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.R;
@ -271,4 +273,20 @@ public class ReportController {
}
}
/**
* ()
* @param paramMap
* @return
*/
@GetMapping("/weekLoadRateReport")
public R weekLoadRateReport(@RequestParam(required = false) Map paramMap){
try{
return R.ok(reportService.weekLoadRateReport(paramMap));
}catch (Exception e){
return R.failed(e.getMessage());
}
}
}

@ -111,4 +111,11 @@ public interface ReportMapper {
* @return
*/
List<Map<String,Object>> qualityRepairReport(Map paramMap);
/**
* ()
* @param paramMap
* @return
*/
List<Map<String, Object>> weekLoadRateReport(Map paramMap);
}

@ -117,4 +117,11 @@ public interface ReportService {
* @return
*/
List<Map<String, Object>> qualityRepairReport(Map paramMap);
/**
* ()
* @param paramMap
* @return
*/
List<Map<String, Object>> weekLoadRateReport(Map paramMap);
}

@ -504,6 +504,19 @@ public class ReportServiceImpl implements ReportService {
return reportMapper.qualityRepairReport(paramMap);
}
/**
* ()
* @param paramMap
* @return
*/
@Override
public List<Map<String, Object>> weekLoadRateReport(Map paramMap) {
String site = CommonMethods.getSite();
paramMap.put("site", site);
paramMap.put("locale", LocaleContextHolder.getLocale().getLanguage());
return reportMapper.weekLoadRateReport(paramMap);
}
/**

@ -1492,4 +1492,66 @@
</if>
</where>
</select>
<select id="weekLoadRateReport" resultType="java.util.HashMap" parameterType="java.util.HashMap">
--资源负荷率报表(周维度)
SELECT CF.VALUE "weekCapacity",WIP.* FROM (WITH WEEK AS (
SELECT TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') WEEK0,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 1 WEEK1,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 2 WEEK2,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 3 WEEK3,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 4 WEEK4,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 5 WEEK5,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 6 WEEK6,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 7 WEEK7,
TRUNC(TO_DATE(TO_CHAR(sysdate, 'yyyy-MM-dd'), 'yyyy-MM-dd'), 'IW') + 7 * 8 WEEK8
FROM DUAL)
SELECT ZSD.OPERATION "operation",
R.DESCRIPTION "resourceDescription",
SUM(CASE
WHEN SYSDATE > ZSD.PLANNED_COMP_DATE THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "tardinessWork",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK0) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK1)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours1",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK1) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK2)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours2",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK2) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK3)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours3",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK3) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK4)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours4",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK4) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK5)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours5",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK5) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK6)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours6",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK6) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK7)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours7",
SUM(CASE
WHEN ZSD.PLANNED_COMP_DATE >= TO_DATE(WEEK.WEEK7) AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(WEEK.WEEK8)
THEN ZSD.DISPATCH_QTY * ZSD.PROD_HOURS ELSE 0 END) "unWorkHours8",
R.RESRCE
FROM Z_SFC_DISPATCH ZSD
LEFT JOIN RESRCE R ON R.SITE = ZSD.SITE AND R.RESRCE = ZSD.RESRCE
CROSS JOIN WEEK
WHERE (ZSD.DISPATCH_STATUS != 'COMPLETE' AND ZSD.DISPATCH_STATUS != 'CANCEL' AND ZSD.DISPATCH_STATUS != 'PAUSE')
AND R.DESCRIPTION IS NOT NULL
AND ZSD.PLANNED_COMP_DATE IS NOT NULL
-- AND ZSD.CREATED_DATE_TIME > TO_DATE(TRUNC(TO_DATE(to_char(sysdate,'yyyy-MM-dd'),'yyyy-MM-dd'),'IW') - 8 * 7)
GROUP BY ZSD.OPERATION, R.DESCRIPTION,R.RESRCE
ORDER BY "tardinessWork" DESC) WIP
LEFT JOIN CUSTOM_FIELDS CF ON CF.ATTRIBUTE ='WEEK_CAPACITY' AND CF.HANDLE = 'ResourceBO:'|| #{site} || ','|| WIP.RESRCE
<where>
1=1
<if test="operation != null and operation != ''">
AND WIP."operation" = #{operation}
</if>
<if test="resourceDescription != null and resourceDescription != ''">
AND WIP."resourceDescription" = #{resourceDescription}
</if>
</where>
</select>
</mapper>

@ -46,6 +46,6 @@ public interface ERPAPIWebService {
WebServiceResponse itemBatchReceive(@WebParam(name = "itemBatchReceiveRequest") ItemBatchReceiveRequest itemBatchReceiveRequest);
@WebMethod(action = "http://service.integration.mesnac.com/test")
WebServiceResponse test(@WebParam(name = "TestSyncRequest") TestSyncRequest testSyncRequest);
/* @WebMethod(action = "http://service.integration.mesnac.com/test")
WebServiceResponse test(@WebParam(name = "TestSyncRequest") TestSyncRequest testSyncRequest);*/
}

@ -254,10 +254,10 @@ public class ERPAPIWebServiceImpl implements ERPAPIWebService {
return response;
}
@Override
/* @Override
public WebServiceResponse test(TestSyncRequest testSyncRequest) {
WebServiceResponse response = new WebServiceResponse();
System.out.println("接收成功:"+testSyncRequest.toString());
return response;
}
}*/
}

@ -1,8 +1,14 @@
package com.foreverwin.mesnac.meapi.controller;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.enums.HandleEnum;
import com.foreverwin.mesnac.meapi.model.CustomFields;
import com.foreverwin.mesnac.meapi.model.Resrce;
import com.foreverwin.mesnac.meapi.service.CustomFieldsService;
import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
@ -10,6 +16,8 @@ import com.foreverwin.modular.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -25,6 +33,9 @@ public class ResrceController {
@Autowired
public ResrceService resrceService;
@Autowired
private CustomFieldsService customFieldsService;
/**
*
@ -218,4 +229,39 @@ public class ResrceController {
List<Map<String, Object>> resourceTypeResourceList = resrceService.getResourceTypeResource(site);
return R.ok(resourceTypeResourceList);
}
/**
*
*
* @param paramMap
* @return
*/
@PostMapping("/weekLoadRateReportSaveAll")
public R weekLoadRateReportSaveAll(@RequestBody Map paramMap) {
try {
List<HashMap<String, String>> resultList = (List<HashMap<String, String>>) paramMap.get("resultList");
ArrayList<CustomFields> CustomFieldsList = new ArrayList<>();
if (paramMap.get("capacity").equals("weekCapacity")) {
for (HashMap<String, String> hashMap : resultList) {
CustomFields customFields = new CustomFields();
customFields.setHandle(HandleEnum.RESOURCE.getHandle(CommonMethods.getSite(), hashMap.get("RESRCE")));
customFields.setAttribute("WEEK_CAPACITY");
customFields.setValue(hashMap.get("weekCapacity"));
CustomFieldsList.add(customFields);
}
} else {
for (HashMap<String, String> hashMap : resultList) {
CustomFields customFields = new CustomFields();
customFields.setHandle(HandleEnum.RESOURCE.getHandle(CommonMethods.getSite(), hashMap.get("RESRCE")));
customFields.setAttribute("MONTH_CAPACITY");
customFields.setValue(hashMap.get("monthCapacity"));
CustomFieldsList.add(customFields);
}
}
customFieldsService.saveOrUpdateCustomFields(CustomFieldsList);
return R.ok("保存成功");
}catch(Exception e){
return R.failed(e.getMessage());
}
}
}
Loading…
Cancel
Save