Commit 1a1e2ab0 authored by 赵啸非's avatar 赵啸非

修改配置文件1

parent 2fe5d69f
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterEntity;
/**
......@@ -15,7 +17,7 @@ public interface MatterService extends ICRUDService<MatterEntity,Long>{
* 站点事项转系统事项
* @param sheetMatterIds
*/
void createMatterbBySheetMatter(Long[] sheetMatterIds);
Rest<String> createMatterbBySheetMatter(Long[] sheetMatterIds,Long siteId, Context context);
/**
* 推荐or取消推荐
......
package com.mortals.xhx.module.matter.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.MatterSourceEnum;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterDatumService;
import com.mortals.xhx.module.sheet.dao.SheetMatterDao;
import com.mortals.xhx.module.sheet.model.SheetMatterEntity;
import com.mortals.xhx.module.sheet.model.SheetMatterQuery;
import com.mortals.xhx.module.sheet.service.SheetMatterService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -17,16 +22,17 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.matter.dao.MatterDao;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.service.MatterService;
import org.springframework.util.ObjectUtils;
import java.util.*;
/**
* MatterService
* 事项申请材料 service实现
*
* @author zxfei
* @date 2022-09-27
*/
* MatterService
* 事项申请材料 service实现
*
* @author zxfei
* @date 2022-09-27
*/
@Service("matterService")
public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, MatterEntity, Long> implements MatterService {
......@@ -34,13 +40,13 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
@Autowired
private ParamService paramService;
@Autowired
private SheetMatterDao sheetMatterDao;
private SheetMatterService sheetMatterService;
@Autowired
private MatterDatumService matterDatumService;
@Override
protected MatterEntity findBefore(MatterEntity params, PageInfo pageInfo, Context context) throws AppException {
if(StringUtils.isNotEmpty(params.getMatterName())){
if (StringUtils.isNotEmpty(params.getMatterName())) {
params.setMatterName("%".concat(params.getMatterName()).concat("%"));
}
return params;
......@@ -63,88 +69,105 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
List<MatterEntity> queryList = this.get(ids,context);
if(CollectionUtils.isNotEmpty(queryList)){
List<MatterEntity> queryList = this.get(ids, context);
if (CollectionUtils.isNotEmpty(queryList)) {
int recommendCount = paramService.getParamIntValue(ParamKey.MATTER_RECOMMEND_COUNT);
for(MatterEntity matterEntity:queryList){
if(matterEntity.getIsRecommend()==1){
for (MatterEntity matterEntity : queryList) {
if (matterEntity.getIsRecommend() == 1) {
recommendCount--;
}
}
paramService.setValueByKey(ParamKey.MATTER_RECOMMEND_COUNT,String.valueOf(recommendCount));
paramService.setValueByKey(ParamKey.MATTER_RECOMMEND_COUNT, String.valueOf(recommendCount));
}
}
@Override
protected void findAfter(MatterEntity entity, PageInfo pageInfo, Context context, List<MatterEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)){
for(MatterEntity matterEntity:list){
if (CollectionUtils.isNotEmpty(list)) {
for (MatterEntity matterEntity : list) {
MatterDatumEntity query = new MatterDatumEntity();
query.setMatterId(matterEntity.getId());
int datumCount = matterDatumService.count(query,context);
int datumCount = matterDatumService.count(query, context);
matterEntity.setDatumCount(datumCount);
}
}
}
@Override
public void createMatterbBySheetMatter(Long[] sheetMatterIds) {
List<SheetMatterEntity> sheetMatterEntityList = sheetMatterDao.get(sheetMatterIds);
if(CollectionUtils.isNotEmpty(sheetMatterEntityList)){
Date now = new Date();
List<MatterEntity> list = new ArrayList<>();
for(SheetMatterEntity sheetMatterEntity:sheetMatterEntityList){
MatterEntity query = new MatterEntity();
query.setSiteId(sheetMatterEntity.getSiteId());
query.setTid(sheetMatterEntity.getTid());
query.setTcode(sheetMatterEntity.getTcode());
List<MatterEntity> queryList = this.find(query);
if(CollectionUtils.isNotEmpty(queryList)){
continue;
}
MatterEntity matterEntity = new MatterEntity();
matterEntity.setSiteId(sheetMatterEntity.getSiteId());
matterEntity.setTid(sheetMatterEntity.getTid());
matterEntity.setTcode(sheetMatterEntity.getTcode());
matterEntity.setTname(sheetMatterEntity.getTname());
matterEntity.setMatterName(sheetMatterEntity.getMatterName());
matterEntity.setEnglishName(sheetMatterEntity.getEnglishName());
matterEntity.setMatterNo(sheetMatterEntity.getMatterNo());
matterEntity.setMatterFullName(sheetMatterEntity.getMatterName());
matterEntity.setTotal(0);
matterEntity.setSort(0);
matterEntity.setIsRecommend(0);
matterEntity.setSource(MatterSourceEnum.AUTO.getValue());
matterEntity.setCreateUserId(1l);
matterEntity.setCreateTime(now);
list.add(matterEntity);
public Rest<String> createMatterbBySheetMatter(Long[] sheetMatterIds, Long siteId, Context context) {
int success = 0;
int fail = 0;
List<SheetMatterEntity> sheetMatterEntityList = sheetMatterService.get(sheetMatterIds, context);
for (SheetMatterEntity sheetMatterEntity : sheetMatterEntityList) {
Boolean bool = updateOrSave(sheetMatterEntity, siteId, context);
if (bool) {
success++;
} else {
fail++;
}
this.dao.insertBatch(list);
}
String msg = "当前加入事项已存在!";
if (sheetMatterIds.length == 1) {
if (success > 0) {
msg = "加入事项成功!";
}
} else if (sheetMatterIds.length > 1) {
if (success > 0 && fail == 0) {
msg = String.format("加入事项成功%d条!", success);
} else if (success > 0 && fail > 0) {
msg = String.format("加入事项成功%d条,重复加入事项%d条!", success, fail);
} else if (success == 0 && fail > 0) {
msg = String.format("重复加入事项%d条!", fail);
}
}
return Rest.ok(msg);
}
private Boolean updateOrSave(SheetMatterEntity sheetMatterEntity, Long siteId, Context context) {
MatterEntity siteMatterEntity = this.selectOne(new MatterQuery().siteId(siteId).tid(sheetMatterEntity.getTid()));
if (ObjectUtils.isEmpty(siteMatterEntity)) {
MatterEntity matterEntity = new MatterEntity();
matterEntity.setSiteId(siteId);
matterEntity.setTid(sheetMatterEntity.getTid());
matterEntity.setTcode(sheetMatterEntity.getTcode());
matterEntity.setTname(sheetMatterEntity.getTname());
matterEntity.setMatterName(sheetMatterEntity.getMatterName());
matterEntity.setEnglishName(sheetMatterEntity.getEnglishName());
matterEntity.setMatterNo(sheetMatterEntity.getMatterNo());
matterEntity.setMatterFullName(sheetMatterEntity.getMatterName());
matterEntity.setTotal(0);
matterEntity.setSort(0);
matterEntity.setIsRecommend(0);
matterEntity.setSource(MatterSourceEnum.AUTO.getValue());
matterEntity.setCreateUserId(this.getContextUserId(context));
matterEntity.setCreateTime(new Date());
this.save(siteMatterEntity, context);
return true;
}
return false;
}
@Override
public void recommend(Long id) {
MatterEntity matterEntity = this.dao.get(id);
if(matterEntity==null){
if (matterEntity == null) {
throw new AppException("数据已更改,请重试");
}
int recommendCount = paramService.getParamIntValue(ParamKey.MATTER_RECOMMEND_COUNT);
Map<String,Object> data = new HashMap<>();
Map<String,Object> condition = new HashMap<>();
condition.put("id",id);
if(matterEntity.getIsRecommend()==0){
if(recommendCount>=RECOMMEND_COUNT){
Map<String, Object> data = new HashMap<>();
Map<String, Object> condition = new HashMap<>();
condition.put("id", id);
if (matterEntity.getIsRecommend() == 0) {
if (recommendCount >= RECOMMEND_COUNT) {
throw new AppException("超过推荐个数");
}
recommendCount++;
data.put("isRecommend",1);
}else {
data.put("isRecommend", 1);
} else {
recommendCount--;
data.put("isRecommend",0);
data.put("isRecommend", 0);
}
this.dao.update(data,condition);
paramService.setValueByKey(ParamKey.MATTER_RECOMMEND_COUNT,String.valueOf(recommendCount));
this.dao.update(data, condition);
paramService.setValueByKey(ParamKey.MATTER_RECOMMEND_COUNT, String.valueOf(recommendCount));
}
}
\ No newline at end of file
package com.mortals.xhx.module.matter.web;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.Rest;
import com.mortals.framework.common.code.YesNo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
......@@ -56,7 +57,7 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
@Override
protected void doListBefore(MatterEntity query, Map<String, Object> model, Context context) throws AppException {
List<OrderCol> orderColList = new ArrayList<>();
orderColList.add(new OrderCol("isRecommend"));
orderColList.add(new OrderCol("isRecommend",OrderCol.DESCENDING));
query.setOrderColList(orderColList);
super.doListBefore(query, model, context);
}
......@@ -68,18 +69,16 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
return super.doListAfter(query, model, context);
}
@RequestMapping(value = {"createMatter"},method = {RequestMethod.POST, RequestMethod.GET})
public String createMatter(Long[] ids) {
Context context = this.getContext();
public String createMatter(Long[] ids,Long siteId) {
// public String createMatter(Long[] ids) {
Map<String, Object> model = new HashMap();
int code = 1;
String busiDesc = "站点事项转事项";
try {
this.service.createMatterbBySheetMatter(ids);
model.put("message_info", "站点事项转事项成功!");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + ids + "]");
Rest<String> rest = this.service.createMatterbBySheetMatter(ids, siteId, getContext());
model.put("message_info", rest.getData());
this.recordSysLog(this.request, rest.getData());
} catch (Exception var7) {
code = -1;
this.doException(this.request, busiDesc, model, var7);
......@@ -87,7 +86,6 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
JSONObject ret = new JSONObject();
ret.put("code", Integer.valueOf(code));
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
......
......@@ -31,14 +31,11 @@ Content-Type: application/json
{}
###短信设置编辑
GET {{baseUrl}}/sms/set/edit?id={{SmsSet_id}}
###添加
GET {{baseUrl}}/matter/createMatter?ids=37,38,39&siteId=1
Accept: application/json
###短信设置删除
GET {{baseUrl}}/sms/set/delete?id={{SmsSet_id}}
Accept: application/json
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment