|
@@ -15,7 +15,10 @@ import com.malk.server.dingtalk.DDConf;
|
|
|
import com.malk.server.dingtalk.DDR_New;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
import com.malk.service.dingtalk.DDClient;
|
|
|
+import com.malk.service.dingtalk.DDClient_Contacts;
|
|
|
+import com.malk.service.dingtalk.DDClient_Workflow;
|
|
|
import com.malk.utils.PublicUtil;
|
|
|
+import com.malk.utils.UtilDateTime;
|
|
|
import com.malk.utils.UtilHttp;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -25,10 +28,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.rmi.CORBA.Util;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -41,7 +46,11 @@ public class McYdServiceImpl implements McYdService {
|
|
|
private DDConf ddConf;
|
|
|
@Autowired
|
|
|
private YDConf ydConf;
|
|
|
+ @Autowired
|
|
|
+ private DDClient_Workflow ddClientWorkflow;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DDClient_Contacts ddClient_contacts;
|
|
|
@Override
|
|
|
@Async
|
|
|
public void updateFormDataVersion(Map map) {
|
|
@@ -239,10 +248,10 @@ public class McYdServiceImpl implements McYdService {
|
|
|
|
|
|
String formInstId = UtilMap.getString(map,"formInstId");//实例id(出库单)
|
|
|
Map d = ydClient.queryData(YDParam.builder().formInstId(formInstId)
|
|
|
- .formUuid("FORM-3208DFE5463549A9A57FB94358A75E80PV5F")
|
|
|
- .appType("APP_GNQ1RGK68X4JNZUEU8RQ")
|
|
|
- .systemToken("XH866P81QDOTQ0218TGZM9WCNXOF24WIP488M7A5")
|
|
|
- .userId("332051151139376769").build(),YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+ .formUuid("FORM-3208DFE5463549A9A57FB94358A75E80PV5F")
|
|
|
+ .appType("APP_GNQ1RGK68X4JNZUEU8RQ")
|
|
|
+ .systemToken("XH866P81QDOTQ0218TGZM9WCNXOF24WIP488M7A5")
|
|
|
+ .userId("332051151139376769").build(),YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
System.out.println("出库单数据:"+d);
|
|
|
List<Map> mapList = (List<Map>)d.get("tableField_m8mo8506");
|
|
|
System.out.println("出库单明细数据:"+mapList);
|
|
@@ -254,7 +263,7 @@ public class McYdServiceImpl implements McYdService {
|
|
|
BigDecimal InventoryCount = BigDecimal.valueOf(0);//库存数量
|
|
|
BigDecimal OutboundQuantity = BigDecimal.valueOf(0);//
|
|
|
if(!map1.get("numberField_m9qdwvu1_value").toString().isEmpty()){
|
|
|
- InventoryCount = new BigDecimal( map1.get("numberField_m9qdwvu1").toString());
|
|
|
+ InventoryCount = new BigDecimal( map1.get("numberField_m9qdwvu1").toString());
|
|
|
}
|
|
|
BigDecimal numberFieldM9qdwvu1 = InventoryCount.subtract( new BigDecimal( map1.get("numberField_m8mo8508").toString()));//存库数量 - 出库数量
|
|
|
System.out.println("出库后数量:"+numberFieldM9qdwvu1);
|
|
@@ -605,40 +614,58 @@ public class McYdServiceImpl implements McYdService {
|
|
|
|
|
|
@Override
|
|
|
public McR shareRecord(Map data) {
|
|
|
- // 执行分享逻辑 [ 拼接后的权限组 ]
|
|
|
- McException.assertParamException_Null(data, "compId, userIds, userId, content, atUserId");
|
|
|
- //开始抓取宜搭对应的子表数据
|
|
|
- String processInstanceId = data.get("processInstanceId").toString();
|
|
|
- ArrayList<Map<String,String>> maps_YD = new ArrayList<>();
|
|
|
- DDR_New ddrNew1 = ydClient.queryData(YDParam.builder().formInstanceId(processInstanceId).build()
|
|
|
- , YDConf.FORM_QUERY.retrieve_id);
|
|
|
- Map data1 = ddrNew1.getFormData();
|
|
|
- List<Map> list = new ArrayList<>();
|
|
|
- if (data1.get("tableField_m2cx8zh5") != null){
|
|
|
- list = (List<Map>) data1.get("tableField_m2cx8zh5");
|
|
|
- }
|
|
|
- Map sss=new HashMap<>();
|
|
|
- sss.put("employeeField_m2cx8zh6",data.get("atUserId").toString().split(","));
|
|
|
- sss.put("textareaField_m2cx8zh7",data.get("content"));
|
|
|
- //原有数据
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- Map sss2 = new HashMap();
|
|
|
- Map map = (Map) list.get(i);
|
|
|
- sss2.put("employeeField_m2cx8zh6",map.get("employeeField_m2cx8zh6_id"));
|
|
|
- sss2.put("textareaField_m2cx8zh7",map.get("textareaField_m2cx8zh7"));
|
|
|
- maps_YD.add(sss2);
|
|
|
- }
|
|
|
- maps_YD.add(sss);//新增数据
|
|
|
- Map map = new HashMap();
|
|
|
- map.put(UtilMap.getString(data, "compId"),UtilMap.getList(data, "userIds"));
|
|
|
- map.put("tableField_m2cx8zh5",maps_YD);
|
|
|
+ String pid = getString(data.get("pid"));
|
|
|
+ if (Strings.isNotBlank(pid)){
|
|
|
+ //发起审批
|
|
|
+ String[] dd = McProject.getDd(pid);
|
|
|
+ String appKey = "";
|
|
|
+ String appSecret = "";
|
|
|
+ if (!PublicUtil.isNull(pid) && dd != null && dd.length >= 2) {
|
|
|
+ appKey = dd[0];
|
|
|
+ appSecret = dd[1];
|
|
|
+ }
|
|
|
|
|
|
- ydClient.operateData(YDParam.builder()
|
|
|
- .formInstId(processInstanceId)
|
|
|
- .updateFormDataJson(JSON.toJSONString(map))
|
|
|
- .build(), YDConf.FORM_OPERATION.update);
|
|
|
+ // 执行分享逻辑 [ 拼接后的权限组 ]
|
|
|
+ McException.assertParamException_Null(data, "compId, userIds, userId, content, atUserId, appUrl, pcUrl");
|
|
|
+ //开始抓取宜搭对应的子表数据
|
|
|
+ String processInstanceId = data.get("processInstanceId").toString();
|
|
|
+ String appUrl = data.get("appUrl").toString();
|
|
|
+ String pcUrl = data.get("pcUrl").toString();
|
|
|
+ List<String> atUserId = (List<String>) data.get("atUserId");
|
|
|
|
|
|
- return McR.success();
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put(UtilMap.getString(data, "compId"),UtilMap.getList(data, "userIds"));
|
|
|
+
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstId(processInstanceId)
|
|
|
+ .updateFormDataJson(JSON.toJSONString(map))
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
+
|
|
|
+ String userIds = String.valueOf(data.get("atUserId"));
|
|
|
+ String[] split = userIds.split(",");
|
|
|
+ ArrayList<String> names = new ArrayList<>();
|
|
|
+ for(Object auserId : split){
|
|
|
+ DDR_New ddrNew = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/user/get", null, ddClient.initTokenParams(), UtilMap.map("userid", auserId), DDR_New.class);
|
|
|
+ Object result = ddrNew.getResult();
|
|
|
+ if (result != null) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(result));
|
|
|
+ String name = jsonObject.getString("name");
|
|
|
+ names.add(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ data.put("content", names.stream().collect(Collectors.joining(",")) + ":" +UtilMap.getString(data, "content"));
|
|
|
+
|
|
|
+ if (UtilMap.getBoolean(data, "isNotice")) {
|
|
|
+ /*查询钉钉人员*/
|
|
|
+ ddClientWorkflow.createTBTask(ddClient.getAccessToken(appKey,appSecret),UtilMap.getString(data, "userId"),"流程分享:"+UtilMap.getString(data, "content"),UtilMap.getString(data, "content"),
|
|
|
+ UtilDateTime.getLocalDateTimeTimeStamp(LocalDate.now().plusDays(7).atTime(LocalTime.MAX)), atUserId,null
|
|
|
+ ,UtilMap.map("appUrl, pcUrl",appUrl+"/processDetail"+"?procInsId="+processInstanceId,pcUrl+"/processDetail"+"?procInsId="+processInstanceId),false,30,UtilMap.map("dingNotify","1"));
|
|
|
+ }
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+ return McR.errorParam("参数缺失!");
|
|
|
}
|
|
|
|
|
|
|