Commit 2434d1fa authored by litengwei's avatar litengwei

至少8人出勤

parent 41a558c7
......@@ -25,6 +25,9 @@ public interface SignMapper extends BaseMapper<Sign> {
List<Map<String, Object>> queryPeopleInfo(@Param("dto") SinStaticDto dto);
List<Map<String, Object>> querySignInfo();
int queryPersonNum(String bizOgrCode);
// Map<String, Object> getSignStatistic(@Param("bizOrgCode") String bizOgrCode, @Param("userId") String userId);
......
......@@ -138,6 +138,16 @@
AND is_delete = 0 AND now() > rec_date
</select>
<select id="querySignInfo" resultType="java.lang.Integer">
SELECT
count(DISTINCT user_id) num, biz_org_name bizOrgName, biz_org_code bizOrgCode
FROM
`cb_sign` cs
WHERE
DATE_FORMAT( cs.sign_time, '%Y-%m-%d' ) = DATE_FORMAT( now(), '%Y-%m-%d' )
GROUP BY biz_org_code
</select>
<!-- <select id="getSignStatistic" resultType="Map">-->
<!-- </select>-->
......
......@@ -19,6 +19,9 @@ import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -26,6 +29,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -38,6 +42,7 @@ import java.util.Map;
*/
@Slf4j
@Service
@EnableScheduling
public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implements ISignService {
@Autowired
......@@ -178,4 +183,43 @@ public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implem
}
return save;
}
/**
* 每日计算当天打卡记录,统计至少8人出勤。。
*
*/
@Scheduled(cron = "${jcs.sign.cron:0 0/3 * * * ?}")
@Transactional(rollbackFor = Exception.class)
public void jcsSignStatic() {
log.info("开始出勤统计=========");
List<Map<String, Object>> mapSign = this.baseMapper.querySignInfo();
List<Map<String, Object>> mapList = new ArrayList<>();
for (Map<String, Object> m : mapSign
) {
// 判断至少8人出勤
if(Integer.parseInt(m.get("num").toString()) < 8) {
Map<String, Object> map = new HashMap<>();
map.put("bizOrgCode", m.get("bizOrgCode"));
map.put("bizOrgName", m.get("bizOrgName"));
mapList.add(map);
}
}
if(mapList.size() > 0) {
try {
emqKeeper.getMqttClient().publish("jcs/sign/put", JSONObject.toJSONString(mapList).getBytes(), 1, false);
} catch (MqttException exp) {
log.info(String.format("发送eqm转kafka消息失败:%s", exp.getMessage()));
}
}
if(mapSign.size() == 0) {
Map<String, Object> map = new HashMap<>();
map.put("bizOrgCode", "");
mapSign.add(map);
try {
emqKeeper.getMqttClient().publish("jcs/sign/put", JSONObject.toJSONString(mapSign).getBytes(), 1, false);
} catch (MqttException exp) {
log.info(String.format("发送eqm转kafka消息失败:%s", exp.getMessage()));
}
}
}
}
\ No newline at end of file
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