feat 物料维护编辑\工单维护新增 代码迁移
This commit is contained in:
parent
00e0126b4a
commit
9eff2f5da8
6
pom.xml
6
pom.xml
@ -43,6 +43,12 @@
|
||||
<version>2.3.1</version> <!-- 根据实际版本调整 -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.0</version> <!-- 请检查以获取最新版本 -->
|
||||
</dependency>
|
||||
|
||||
<!-- 分页 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
|
@ -0,0 +1,153 @@
|
||||
package com.cim.idm.controller;
|
||||
|
||||
import com.cim.idm.framework.IDMFrameServiceProxy;
|
||||
import com.cim.idm.framework.data.EventInfo;
|
||||
import com.cim.idm.response.BaseResponse;
|
||||
import com.cim.idm.response.RespGenerator;
|
||||
import com.cim.idm.utils.DingTalkSender;
|
||||
import com.cim.idm.utils.DingTalkUtils;
|
||||
import com.cim.idm.utils.EventInfoUtil;
|
||||
import com.cim.idm.wmspackage.material.MaterialServiceProxy;
|
||||
import com.cim.idm.wmspackage.material.management.data.MaterialSpecKey;
|
||||
import com.cim.idm.wmspackage.material.management.info.SetSpecEventInfo;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@EnableAutoConfiguration
|
||||
@RequestMapping("/api/materialMaint")
|
||||
public class MaterialBasicRoleController {
|
||||
|
||||
@RequestMapping(value = "/editMaterial", method = RequestMethod.POST)
|
||||
public BaseResponse<Map<String, Object>> editMaterial(@RequestBody Map<String,Object> param){
|
||||
|
||||
String siteName = (String)param.get("SITENAME");
|
||||
String materialspecname = (String)param.get("MATERIALSPECNAME");
|
||||
Number expirationday_t = (Number)param.get("EXPIRATIONDAY_T");
|
||||
String is_con_temp_t = (String)param.get("IS_CON_TEMP_T");
|
||||
String maturationflag_t = (String)param.get("MATURATIONFLAG_T");
|
||||
String maturationtime_t = (String)param.get("MATURATIONTIME_T");
|
||||
String funit_t = (String)param.get("FUNIT_T");
|
||||
String unit_rates_t = (String)param.get("UNIT_RATES_T");
|
||||
String iqcflag_t = (String)param.get("IQCFLAG_T");
|
||||
String inspection_cycle_t = (String)param.get("INSPECTION_CYCLE_T");
|
||||
String user = (String)param.get("user");
|
||||
String is_check = (String)param.get("IS_CHECK");
|
||||
|
||||
// String sql = "UPDATE MATERIALSPEC " +
|
||||
// "SET EXPIRATIONDAY_T = ?, IS_CON_TEMP_T = ?, MATURATIONFLAG_T = ?, " +
|
||||
// "MATURATIONTIME_T = ?, FUNIT_T = ?, UNIT_RATES_T = ?, IQCFLAG_T = ?, INSPECTION_CYCLE_T = ? " +
|
||||
// "WHERE MATERIALSPECNAME = ? AND SITENAME = ?";
|
||||
//
|
||||
// Object[] args = new Object[]{expirationday_t, is_con_temp_t, maturationflag_t, maturationtime_t,
|
||||
// funit_t, unit_rates_t, iqcflag_t, inspection_cycle_t,materialspecname, siteName};
|
||||
|
||||
// IDMFrameServiceProxy.getSqlTemplate().update(sql, args);
|
||||
|
||||
MaterialSpecKey key = new MaterialSpecKey();
|
||||
key.setSiteName(siteName);
|
||||
key.setMaterialSpecName(materialspecname);
|
||||
|
||||
SetSpecEventInfo info = new SetSpecEventInfo();
|
||||
Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||
|
||||
bindMap.put("EXPIRATIONDAY_T", expirationday_t);
|
||||
bindMap.put("IS_CON_TEMP_T", is_con_temp_t);
|
||||
bindMap.put("MATURATIONFLAG_T", maturationflag_t);
|
||||
bindMap.put("MATURATIONTIME_T", maturationtime_t);
|
||||
bindMap.put("FUNIT_T", funit_t);
|
||||
bindMap.put("UNIT_RATES_T", unit_rates_t);
|
||||
bindMap.put("IQCFLAG_T", iqcflag_t);
|
||||
bindMap.put("INSPECTION_CYCLE_T", inspection_cycle_t);
|
||||
bindMap.put("IS_CHECK", is_check);
|
||||
|
||||
info.setUserColumns(bindMap);
|
||||
|
||||
EventInfo eventInfo = new EventInfoUtil().makeEventInfo("EditMaterial", user, "EditMaterial");
|
||||
eventInfo.setEventName("ModifyMaterialSpec");
|
||||
|
||||
MaterialServiceProxy.getMaterialSpecService().setEvent(key, eventInfo, info);
|
||||
|
||||
String message = materialspecname + " 已经修改,待审核" ;
|
||||
String accessToken = null;
|
||||
try {
|
||||
accessToken = DingTalkUtils.getAccessToken();
|
||||
} catch (IOException e) {
|
||||
System.out.println("获取accessToken异常: " + e.getMessage());
|
||||
}
|
||||
String agentId = "3206304704"; // 如果API调用不需要,则忽略此参数
|
||||
String chatId = "";
|
||||
String getIDSql = "SELECT m.MESSAGEID FROM MESSAGEPUSHDETAIL m WHERE m.DEPARTMENT = 'test'";
|
||||
List<Map<String,Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(getIDSql);
|
||||
for(Map<String,Object> map : queryForList) {
|
||||
chatId = chatId + map.get("MESSAGEID").toString() + ",";
|
||||
}
|
||||
String dingId = chatId.substring(0, chatId.length()-1);
|
||||
|
||||
try {
|
||||
//钉钉推送
|
||||
DingTalkSender.sendTextMessage(accessToken, agentId, dingId, dingId, message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("钉钉推送异常: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
BaseResponse returnOK = RespGenerator.returnOK(param);
|
||||
return returnOK;
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/checkMaterial", method = RequestMethod.POST)
|
||||
public BaseResponse<Map<String, Object>> checkMaterial(@RequestBody Map<String,Object> param){
|
||||
|
||||
String siteName = (String)param.get("SITENAME");
|
||||
String materialspecname = (String)param.get("MATERIALSPECNAME");
|
||||
Number expirationday_t = (Number)param.get("EXPIRATIONDAY_T");
|
||||
String is_con_temp_t = (String)param.get("IS_CON_TEMP_T");
|
||||
String maturationflag_t = (String)param.get("MATURATIONFLAG_T");
|
||||
String maturationtime_t = (String)param.get("MATURATIONTIME_T");
|
||||
String funit_t = (String)param.get("FUNIT_T");
|
||||
String unit_rates_t = (String)param.get("UNIT_RATES_T");
|
||||
String iqcflag_t = (String)param.get("IQCFLAG_T");
|
||||
String inspection_cycle_t = (String)param.get("INSPECTION_CYCLE_T");
|
||||
String user = (String)param.get("user");
|
||||
String is_check = (String)param.get("IS_CHECK");
|
||||
|
||||
MaterialSpecKey key = new MaterialSpecKey();
|
||||
key.setSiteName(siteName);
|
||||
key.setMaterialSpecName(materialspecname);
|
||||
|
||||
SetSpecEventInfo info = new SetSpecEventInfo();
|
||||
Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||
|
||||
bindMap.put("EXPIRATIONDAY_T", expirationday_t);
|
||||
bindMap.put("IS_CON_TEMP", is_con_temp_t);
|
||||
bindMap.put("MATURATIONFLAG", maturationflag_t);
|
||||
bindMap.put("MATURATIONTIME", maturationtime_t);
|
||||
bindMap.put("FUNIT", funit_t);
|
||||
bindMap.put("UNIT_RATES", unit_rates_t);
|
||||
bindMap.put("IQCFLAG", iqcflag_t);
|
||||
bindMap.put("INSPECTION_CYCLE", inspection_cycle_t);
|
||||
bindMap.put("IS_CHECK", is_check);
|
||||
|
||||
info.setUserColumns(bindMap);
|
||||
|
||||
EventInfo eventInfo = new EventInfoUtil().makeEventInfo("CheckMaterial", user, "CheckMaterial");
|
||||
eventInfo.setEventName("CheckMaterialSpec");
|
||||
|
||||
MaterialServiceProxy.getMaterialSpecService().setEvent(key, eventInfo, info);
|
||||
|
||||
BaseResponse returnOK = RespGenerator.returnOK(param);
|
||||
return returnOK;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package com.cim.idm.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cim.idm.framework.IDMFrameServiceProxy;
|
||||
import com.cim.idm.utils.AjaxResult;
|
||||
import com.cim.idm.utils.CommonUtils;
|
||||
import com.cim.idm.wmsextend.generic.errorHandler.CustomException;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工单-生产订单
|
||||
* @author ZXYGY17
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/WorkOrder")
|
||||
@EnableAutoConfiguration
|
||||
public class WorkOrderController {
|
||||
|
||||
CommonUtils untils=new CommonUtils();
|
||||
|
||||
@RequestMapping(value = "/Add", method = RequestMethod.POST)
|
||||
public AjaxResult AddWorkOrder(@RequestBody JSONObject in ) throws Exception {
|
||||
String userId = in.get("userId").toString();
|
||||
String workOrder = in.get("workOrder").toString();
|
||||
|
||||
Map<String, Object> hashMap = new HashMap<String,Object> ();
|
||||
hashMap.put("WORKORDER", workOrder);
|
||||
String qySql = "SELECT 1 FROM WORKORDER w WHERE WORKORDER = :WORKORDER";
|
||||
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(qySql, hashMap);
|
||||
if(queryForList != null && queryForList.size() > 0) {
|
||||
throw new CustomException("工单号已经存在!");
|
||||
}
|
||||
|
||||
hashMap.put("CREATENAME", userId);
|
||||
String addSql = "INSERT INTO WORKORDER (WORKORDER, CREATETIME, CREATENAME)\r\n" +
|
||||
"VALUES (:WORKORDER, SYSDATE, :CREATENAME)";
|
||||
try {
|
||||
IDMFrameServiceProxy.getSqlTemplate().update(addSql, hashMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("保存错误:" + e);
|
||||
}
|
||||
return AjaxResult.me().setSuccess(true).setResultObj(null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/Del", method = RequestMethod.POST)
|
||||
public AjaxResult DeleteWorkOrder(@RequestBody JSONObject in ) throws Exception {
|
||||
String workOrder = in.get("workOrder").toString();
|
||||
|
||||
Map<String, Object> hashMap = new HashMap<String,Object> ();
|
||||
hashMap.put("WORKORDER", workOrder);
|
||||
String qySql = "DELETE FROM workOrder WHERE WORKORDER = :WORKORDER";
|
||||
IDMFrameServiceProxy.getSqlTemplate().update(qySql, hashMap);
|
||||
return AjaxResult.me().setSuccess(true).setResultObj(null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
|
||||
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam(value="userId",defaultValue="") String userId) throws Exception {
|
||||
|
||||
try {
|
||||
Workbook workbook = WorkbookFactory.create(file.getInputStream());
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
int index = 0;
|
||||
for (Row row : sheet) {
|
||||
|
||||
System.out.println(row.getCell(row.getRowNum()));
|
||||
index++;
|
||||
if(row.getCell(row.getRowNum()) != null) {
|
||||
for (Cell cell : row) {
|
||||
if(cell != null ) {
|
||||
// 类型都转为字符串
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
String cellValue = cell.getStringCellValue();
|
||||
// if(index == 1 && !"工单".equals(cellValue) ) {
|
||||
// throw new RuntimeException("非工单信息!");
|
||||
// }
|
||||
if(!cellValue.isEmpty() && index > 1) {
|
||||
// System.out.println(cellValue);
|
||||
// System.out.println(index);
|
||||
Map<String, Object> hashMap = new HashMap<String,Object> ();
|
||||
hashMap.put("WORKORDER", cellValue);
|
||||
hashMap.put("CREATENAME", userId);
|
||||
String addSql = "INSERT INTO WORKORDER (WORKORDER, CREATETIME, CREATENAME)\r\n" +
|
||||
"VALUES (:WORKORDER, SYSDATE, :CREATENAME)";
|
||||
IDMFrameServiceProxy.getSqlTemplate().update(addSql, hashMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("导入错误(工单不能重复):" + e);
|
||||
}
|
||||
return AjaxResult.me().setSuccess(true).setResultObj(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.cim.idm.utils;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DingTalkSender {
|
||||
|
||||
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
|
||||
|
||||
|
||||
public static void sendTextMessage(String accessToken, String agentId, String userId, String chatId, String message) throws IOException {
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
|
||||
|
||||
String json = "{\"agent_id\":\"" + agentId + "\",\"userid_list\":\"" + userId + "\",\"deptid_list\":[\"" + userId + "\"],\"chatid\":\"" + chatId + "\",\"msg\":{\"msgtype\": \"text\",\"text\": {\"content\": \"" + message + "\"}}}";
|
||||
|
||||
|
||||
|
||||
RequestBody body = RequestBody.create(json, JSON);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
|
||||
.url("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=" + accessToken)
|
||||
|
||||
.post(body)
|
||||
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
|
||||
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
||||
|
||||
|
||||
|
||||
System.out.println(response.body().string());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String accessToken = DingTalkUtils.getAccessToken();
|
||||
String agentId = "3206304704"; // 如果API调用不需要,则忽略此参数
|
||||
String chatId = "095452471826097763,02000826241189265"; // 账号
|
||||
String message = "Hello, this is a test message from Java!"; //发送内容
|
||||
|
||||
sendTextMessage(accessToken, agentId, chatId, chatId,message);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.cim.idm.utils;
|
||||
|
||||
import com.cim.idm.framework.IDMFrameServiceProxy;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DingTalkUtils {
|
||||
|
||||
private static final String APP_KEY = "dingdz6no5d2igfucd8h"; //AppKey
|
||||
private static final String APP_SECRET = "YB0ieklneXHEUZ0dyRxu36w9AKSbjqVpS7z6iPE1_3YzTvS3yeQ-jieeP4Al0sIW";
|
||||
|
||||
public static String getAccessToken() throws IOException {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
String url = "https://oapi.dingtalk.com/gettoken?appkey=" + APP_KEY + "&appsecret=" + APP_SECRET;
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) throw new IOException("Failed to retrieve access token");
|
||||
|
||||
String responseBody = response.body().string();
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
return jsonObject.getString("access_token");
|
||||
}
|
||||
}
|
||||
|
||||
// ... 其他方法
|
||||
|
||||
//获取维护的钉钉号或邮箱。zd.2024.9.9
|
||||
public static String getEnumDef(String enumName)
|
||||
{
|
||||
String resultList="";
|
||||
|
||||
String sql="SELECT LISTAGG(e.ENUMVALUE, ', ') WITHIN GROUP (ORDER BY e.ENUMVALUE) AS ENUMVALUE\r\n" +
|
||||
" FROM ENUMDEFVALUE e WHERE e.ENUMNAME =:ENUMNAME ";
|
||||
Map<String,Object> bp=new HashMap<>();
|
||||
bp.put("ENUMNAME", enumName);
|
||||
List<Map<String,Object>> sr=IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bp);
|
||||
if(sr.size()>0)
|
||||
{
|
||||
resultList=sr.get(0).get("ENUMVALUE")==null?"":sr.get(0).get("ENUMVALUE").toString();
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user